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

Re : Howto: listen for view change event?

$
0
0
Written as Mustache:

  1. <div>
  2. <div>
  3. <div {{ (el) -> updateScrollbar(el); }} ></div>
  4.       </div>
  5. </div>
A couple of notes and caveats, though:
* You see that there's no "self" in the Mustache version.  The script snippets aren't passed the scope or any controller reference, and you can't look up the DOM because the view is not attached to the document yet.  updateScrollbar has to be put somewhere globally accessible.
* If you need dimension measurements, you can't use this syntax because it operates on the element before it's attached to the DOM.  This is why the "inserted" event is so important.
* can.Stache in 2.1 doesn't support this syntax, so you would have to rewrite it if you want to start using Stache later.

Viewing all articles
Browse latest Browse all 3491

Trending Articles