I have a simple backbone app called from other app.
It's seems a dialog box to view message like "Welcome user" or "update succesfull".
I have created this app and when I call it the first time all variable is set: title and message but when I call it the second, third times value aren't updated but in console I see the variable change!
This is my view simplified I pass to it same value
var StatusMessageView = Backbone.View.extend({
template : tmplStatusMessage,
model : new StatusMessageModel(),
initialize : function (data) {
this.listenTo(this.model, "change", this.render);
this.model.set(data);
},
render : function () {
console.log("View - StatusMessage.render msg: " + this.model.get('message'));
var template = Handlebars.compile(this.template);
var html = template(this.model.toJSON());
//-----------INTO THIS CONSOLE LOG I SEE HTML UPDATED!!! WHY???
console.log('HTML: ' + html);
if($("#status-message").length === 0) {
$("body").append(html);
}
//AFTER A DELAY I CLOSE THE APP
var self = this;
var intro_timer = setTimeout(function () {
$("#status-message").addClass("enter");
var outro_timer = setTimeout(function () {
self.closeMessage();
}, 5000);
}, 500);
}
});
To update into another view I use this code for exampl and the message is good if I trace it into the console:
statusMessageView.model.set({
title : title,
message : msg
});
Why the html is updated, variable is updated in console log but not into the template I think?