I create one sign in view, and put it in other main views.
Here is one of a main view :
define(["jquery" ,
"underscore" ,
"backbone" ,
"webconfig",
"text!templates/header.html",
"text!templates/signInTemplate.html" ,
"text!templates/miniSignInTemplate.html",
"text!templates/footer.html"
],function($ , _ , Backbone, WebConfig, HeaderTem, SignInTem, MiniSignInTem, FooterTem){
var signInView = Backbone.View.extend({
initialize : function(){
},
el: '#webbodycontainer',
render : function(){
this.$el.empty();
var headerTem = _.template(HeaderTem);
var signInTem = _.template(SignInTem);
var miniSignInTem = _.template(MiniSignInTem);
var footerTem = _.template(FooterTem);
$("#webheader").html(headerTem);
this.$el.html(signInTem);
$("#rightpanel").html(miniSignInTem);
$("#webfooter").html(footerTem);
}
});
return signInView;
});
And here is a sub view :
define(["jquery" ,
"underscore" ,
"backbone" ,
"webconfig",
"text!templates/miniSigninTemplate.html"
],function($ , _ , Backbone , WebConfig , signinTemp){
var MiniView = Backbone.View.extend({
initialize:function(){
this.render();
},
event : {
'click #signIn' : 'signInUser'
},
signInUser : function(){
alert(1);
},
render:function(){
var template = _.template(signinTemp)
this.$el.html(template);
}
});
return MiniView;
});
Routing main view :
app_router.on('route:signInAction', function(signIn){
if(window.currentSection)
window.currentSection.remove();
window.currentSection = new SignIn({});
$("#webbodycontainer").html(window.currentSection.$el);
window.currentSection.render(signIn);
});
Problem : signInUser
in sub view is not working also the whole view (MiniView) is not called. Did I miss something?
Any help would be much appreciated, thank you..