Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Nested controls in a live binded template

$
0
0
Hi,
I'm using CanJS 1.1. 

I have a tabs Control and each tab has a Resources control. The tabs "state" is represented by an Observe object.

In my tabs Control, I render a "placeholder", e.g. "<div class='resources'></div>",and I want to create a new resources control with this DIV. So I need the control initialisation code to run whenever a new placeholder is rendered. At the moment, I have an event handler (Line 12) that listens to the tabs Observe, but the problem is that this runs before the rendering and I need it to run after.

Any thoughts would be appreciated.

  1. init: function(){
  2. var _this = this;
  3. ......
  4. _this.element.html(can.view("//imsportal/controllers/resources_tabbed/views/tabs.ejs", {tabs: _this.options.tabs, items: _this.options.items}));
  5. var filterOptionsPromise = Portal.Filters[_this.options.tab_by].getFilterOptions();
  6. filterOptionsPromise.done(function(options){
  7. _this.options.tabs.replace(options);
  8. });
  9. }
  10. ,
  11. "{tabs} length": function(){
  12. var _this = this;
  13. _this.element.find(".resources").each(function(){
  14. new Portal.Resources(this, {});
  15. });
  16. }


Thanks,
Bryon

Viewing all articles
Browse latest Browse all 3491

Trending Articles