I’m assuming I am missing something because so far any feature I’ve needed has been in ember.js, even if just undocumented. (Yay github)
So how exactly am I supposed to use jquery.ui with views that have conditional sub views?
So say this is my template
<ul>
<li>Item 1</li>
{{#if someBinding}}
<li>Item 2</li>
{{/if}}
<li>Item 3</li>
</ul>
And in my corresponding view…
someView = Ember.View.extend({
...
didInsertElement: function() {
this.$('ul>li').button();
}
...
});
So the problem with this is that the view will be rendered into the DOM with Item 1 & 3 and then call didInsertElement. So Item 2 will not be built properly.
And manually observing ‘someBinding’ will fire before the conditional view is added to the DOM as well, so that’s no help.
So is there an event or some way I can call my jQuery once all views are in and binding synced?
This solution works for a ‘statical’ rendering (
stuffvalue set before rendering, and not changing…):Handlebars
JS
You where missing the scope
view.in the view.Working JSFiddle here: http://jsfiddle.net/MikeAski/H6MNj/
For a
stuffvalue changing through the time, try decoupling theItem 2rendering, and nesting it in a subview which will contain conditional display logic.Handlebars
JS
JSFiddle updated @ http://jsfiddle.net/MikeAski/H6MNj/3/
Another possible approach would consist to render a list of item, which may vary, using a
CollectionView(oreachhelper).Let me know if you wish to have a sample.