1

Expanding my original question located here

If my Userview is in Userview.js file and I want to inherit from that class in AdminView.js file, how would I go about it.

I tried this, but would not fit my need as I don't have a class.

UPDATE 1:

define([
    'modules/userdetail'
],

function(UserView) {
    var adminView
    adminView.Views.Content = UserView.Views.Content.extend({
        initialize: function() {
                 //looking to override the fn that is declared in UserView
        console.log("AAA");
        },
    });
}

UPDATE 2: So digging deep, the User Detail is

define(
        [ 'modules/baseClass'],

        function(BaseClass) {
            
            // Create a new module
            
            //Create Model
            
            //Create View
            UserDetails.Views.Content = Backbone.View
                    .extend({
                        template : 

                        initialize : function() {
                            this.model = new UserDetails.Model();
                        },

                        events : {
                            
                        },

                        
                        render : function(LayOut) {
                            
                            return LayOut(this).render().then(this.pageReady);
                        },

                        pageReady : function() {
                        },

                        
                    });

                    UserDetails.activate = function() {
                        app.router.navigate('UserDetails', true);
                    };

                    UserDetails.configureRouting = function() {
                        app.router.route('UserDetails', 'UserDetails',
                        function() {
                            layoutmanager.setView('#content',
                                    new UserDetails.Views.Content())
                                    .render();
                        });
                    };

                    
                    return UserDetails;

        });

ADMIN:

define([
    'modules/baseclass',
    'modules/UserDetail'
],

function(BaseClass, UserDetails) {
    
    
    UserDetail.Views.Content = UserDetail.Views.Content.extend({
            render:function(){
                console.log("rendering");
                UserDetail.Views.Content.prototype.render();
            }
    });
    
    
    //create admin model
    
    //admin view
    AdminView.Views.Content = Backbone.View.extend({
        
        template: "admin-template",
        
        events: {
        },
        
        initialize: function() {
            this.model = new AdminModel.Model();
        },
            
        render: function(manage) {
            return manage(this).render().then(this.pageReady);
        },
        
        pageReady: function() {
            
            });
            
            
        },
        
        
        
    AdminView.activate = function() {
        app.router.navigate('adminview', true);
    };
    
    AdminView.configureRouting = function() {
        app.router.route('adminview', 'adminview', function() {
            layoutmanager.setView('#content', new AdminView.Views.Content()).render();
            layoutmanager.setView('#userDetials', new UserDetials.Views.Content()).render();
            
        });
    };
    
    if(app.router && app.router.route) {
        AdminView.configureRouting();
    }
    
    return AdminView;
});

Now if I have to call the render of the userdetails from admin view, the render method fails as the param is undefined.

I am not well versed with where the para in render is defined as I looked through my code and have not found anything

Community
  • 1
  • 1

1 Answers1

0

Either include the script tag for Userview.js before the script tag for AdminView.js, or using a module system like requirejs or browserify where you can specify the two modules as dependencies.

blockhead
  • 9,655
  • 3
  • 43
  • 69