below router function have id parameter.my question how pass id camp views..thanks..i tried following..when alert in views says undefined
router.js
editcampaign :function(id){ $('#content').empty(); require([ 'views/camp' ], function(editcampaign) { $('#content').html(new editcampaign({campaignid:id}).render().$el); }); },
views.js
sm.views.editcampaign = backbone.view.extend({myid:id , template : _.template(editcampaigntnpl), campaignid : 0, initialize : function() { _self1=this; alert(myid); //this says undefined this.campaign = new campaign(); this.newscenario = new newscenarioview(); },
just add initialize function first line:
initialize : function(options) { this.campaignid = options.campaignid; // <=== this.myid = options.campaignid; _self1=this; alert(myid); //this says undefined this.campaign = new campaign(); this.newscenario = new newscenarioview(); },
Comments
Post a Comment