Live updating views #171

Closed
sweiz opened this Issue May 1, 2013 · 1 comment

Comments

Projects
None yet
1 participant
@sweiz

sweiz commented May 1, 2013

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.

@sweiz

This comment has been minimized.

Show comment
Hide comment
@sweiz

sweiz May 1, 2013

It now works, and I don't know what I've done to make it work; quite likely I'm retarded. Please close this issue if possible.

Full props for blade, loving it!

sweiz commented May 1, 2013

It now works, and I don't know what I've done to make it work; quite likely I'm retarded. Please close this issue if possible.

Full props for blade, loving it!

@sweiz sweiz closed this May 1, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment