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

Re : Custom view render

$
0
0
This is a great question, because it delves into some of the tricky things that you can pull off in Mustache helpers, using can.view.hook, can.view.live, and the "inserted" event.

In fact, it took me a few tries to get the flow just right.  One thing you have to watch out for is that when setting up some live areas using can.view.live, your old element may be detached on calls to your compute after the first one, so you can't just rely on the element being inserted in the DOM each time your live compute fires.

The real trick here is to grab the parent node of the element the first time it's attached, and use that, along with the parent's existing height (since after the first call it will already have markup) to check whether we should make new divs.

I've constructed a working and documented fiddle but it's probably a bit hard to understand for new users anyone:   http://jsfiddle.net/air_hadoken/6LpSs/3/

Ask any questions you have about it.

Viewing all articles
Browse latest Browse all 3491

Trending Articles