component / reactive

Tiny reactive template engine
383 stars 48 forks source link

data-{visible|hidden} not reacting to changes #137

Closed cristiandouce closed 10 years ago

cristiandouce commented 10 years ago

I just find trying to build an example on hide/show elements on a view reacting to changes on a model. But I can't make it work.

I went by hide.html example and modified the filename property on a setTimeout, but no change observed on the view.

Is this on purpose? Am I missing some manual binding or something?

Thanks!

cristiandouce commented 10 years ago

Ok. I found the issue. Say for instance I bind to data-visible a function isBob which tests a model attribute to "Bob" === this.firstname.

The problem appears when running reactive.set('firstname', 'Bob'). (or any set with "change firstname" event emit)

I mean, when the firstname changes, data-visible does not trigger again it's validation. So I have to proxy-plug the set method of my model, to this.reactive.emit('change isBob') anytime I set "firstname".

defunctzombie commented 10 years ago

Yes. This is by design. We can't know when isBob changes if you don't emit the change event for isBob. What I do in these cases is have a model layer that supports "computed properties" or as you did, just emit the change even manually.

cristiandouce commented 10 years ago

Or support interpolation :dancer: haha