You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
first of all, thanks for this. This is the first sane approach & model <-> view bindings in backbone i´ve seen so far.
I recently was in the situation that i needed to change the 'view.el' elements class,
after digging into the sources i was not able to find a way to do that (maybe I missed smth.)
So, i added a 'custom selector' named ':el', by changing line 51 from
$el=self.$(selector);
to
$el=selector=':el' ? self.$el : self.$(selector);
Now you can use your bindings to do smth. like this:
@asciidisco This a great idea - I'm surprised I haven't needed this yet! I pushed this into master and I'll cut a tag and write some docs soon.
In your example, it looks like you are toggling visibility on the element. If so, I recently pushed some api changes to master which may help, or at least be more intuitive. For example:
bindings: {':el': {modelAttr: 'hidden',// Turns on show/hide toggling, which will be toggled based on the `hidden` attributes change in truthiness.// May also define a callback function which should return true or false after the `hidden` attribute is changed.visible: true,// Optionally, if you want a better animation than the standard jQuery show()/hide(), you can define the// following key and callback, and manually show and hide the bound element.visibleFn: function($el,isVisible,attrName){if(isVisible)$el.fadeIn('fast');else$el.fadeOut('fast');}}
Hi,
first of all, thanks for this. This is the first sane approach & model <-> view bindings in backbone i´ve seen so far.
I recently was in the situation that i needed to change the 'view.el' elements class,
after digging into the sources i was not able to find a way to do that (maybe I missed smth.)
So, i added a 'custom selector' named ':el', by changing line 51 from
to
Now you can use your bindings to do smth. like this:
Your thoughts?
Would love to see this in core.
Regards
Sebastian
The text was updated successfully, but these errors were encountered: