I'm attempting to update the views from outside the template, but the view will not reflect the changes to the model unless I re-render it;
var thisModel = new blade.model({"title": "Hello World"});
$('wrap').render('wrapView', thisModel, function() {
thisModel.set("title", "Hello Earth") // Doesn't update view unless I run render again.
}):
Have tried;
model.add("clicks", 0);
var x = model.observable;
console.log(x.clicks); //calls model.get("clicks") and prints 0
x.clicks = 20; //calls model.set("clicks", 20)
and
var users = [ ...data goes here... ];
var m = new blade.Model({"users": users});
//... Then later...
users[2].firstName = "Ben"; //This does not trigger Model.set or invalidate any contexts
//Nor does this...
m.observable.users[2].firstName = "Ben"; //This only calls Model.get
//To actually invalidate Contexts, you have to invoke Model.set... but wait...
m.set("users", users); //Oh, crap! Even this didn't work because the value was unchanged!
m.invalidate("users"); //Finally, it works! (invalidate() function was added in Blade 2.6.0)
from the wiki but neither seem to work unless I re-render the view. Am I missing something? Any help would be greatly appreciated.
I'm attempting to update the views from outside the template, but the view will not reflect the changes to the model unless I re-render it; var thisModel = new blade.model({"title": "Hello World"}); $('wrap').render('wrapView', thisModel, function() { thisModel.set("title", "Hello Earth") // Doesn't update view unless I run render again. }):
Have tried;
model.add("clicks", 0); var x = model.observable; console.log(x.clicks); //calls model.get("clicks") and prints 0 x.clicks = 20; //calls model.set("clicks", 20)
and
var users = [ ...data goes here... ]; var m = new blade.Model({"users": users}); //... Then later... users[2].firstName = "Ben"; //This does not trigger
Model.set
or invalidate any contexts //Nor does this... m.observable.users[2].firstName = "Ben"; //This only callsModel.get
//To actually invalidate Contexts, you have to invokeModel.set
... but wait... m.set("users", users); //Oh, crap! Even this didn't work because the value was unchanged! m.invalidate("users"); //Finally, it works! (invalidate() function was added in Blade 2.6.0)from the wiki but neither seem to work unless I re-render the view. Am I missing something? Any help would be greatly appreciated.