I just started working in Backbone.js
In that I created a simple example of showing the values in the template using the underscore.js
Now I want to create some advanced example of showing the values of a user in the template using the model thing

Now my model is (EditProfileModel.js):
window.EditProfileModel = Backbone.Model.extend({
constructor : function(attributes, options) {
Backbone.Model.apply(this, arguments);
},
defaults : {
id : '',
firstName : '',
lastName : '',
},
urlRoot: 'rest/editProfile'
});
EditProfileView.js :
window.EditProfileView = Backbone.View.extend({
template : 'tpl/EditProfileTpl.html',
el: content,
initialize:function () {
this.render();
},
events: {
},
render:function () {
var $this = this;
var editProfileModel = new EditProfileModel({
id:this.model.get('id')
});
//GET editProfile/id
editProfileModel.fetch({
success : function(model){
//console.log("I am fetch " + JSON.stringify(model));
TemplateManager.get($this.template, function(template){
console.log($(template).html());
var html = _.template($(template).html(),{user : model});
$this.$el.html(html);
return $this;
});
}
});
},
});
and main.js with router thing is:
.....
routes : {
"profile/:id" : "editProfile"
},
editProfile : function(id){
var $this = this;
$this.model = new EditProfileModel({
id:id
});
$('#content').html(
new EditProfileView({
model: $this.model
})
);
}
......
TemplateManager is just a javascript code that fetches the template on demand and stores it in the array and send the same template back if requested second time from its memory.(I got its code here)
But its showing like this :

(see the textbox value it should be admin as it is returned from the server)
Please help me, this is really wierd..................
:(
this is the html that is coming from the server (template):::
<div>
<form id="frmEditProfile" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="firstName">FirstName</label>
<div class="controls">
<input id="firstName" name="firstName" placeholder="firstName" value="<%=model.get('firstName')%>" autofocus="autofocus">
</div>
</div>
<div class="control-group">
<label class="control-label" for="lastName">LastName</label>
<div class="controls">
<input type="text" id="lastName" name="lastName" placeholder="lastName">
</div>
</div>
<input type="hidden" name="id" value="">
<div class="control-group">
<div class="controls">
<button class="btn btn-primary" id="btnSave" type="submit">
<i class="icon-ok"></i> Save
</button>
</div>
</div>
</form>
</div>