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

Re : Rebind on() with live template

$
0
0
Couple things I noticed, you are binding the control and event handler to the dynamically generated offers as opposed top the parent dom element, #wrapper.  Why not instantiate the control on wrapper and click events will be delegated to any number added later.  So for sake of testing, if you changed to: 
  1. can.Control.extend('mynamespace.fooController',{
  2.   init: function( element , options ) {
  3.       
  4.   },
  5.   '.offer click': function( $ct, evt ){
  6.       alert( $ct.index() );
  7.   }
  8.                         
  9. });
  10. new mynamespace.fooController('#wrapper');
Then you don't even need to rebind.  Does that make sense?

Viewing all articles
Browse latest Browse all 3491

Trending Articles