Add $.fn.view method, which links any jquery element to its parent view.

When generating a jQuery fragment with the templating framework, I store the fragment in the 'view' data property on all the fragments elements. This allows us to query an element from the DOM and determine what view object it belongs to.
This commit is contained in:
Nathan Sobo
2011-12-30 12:05:11 -06:00
parent e4d73ace25
commit dc38a0e375
3 changed files with 10 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ class Builder
toFragment: ->
fragment = $(@toHtml())
@wireOutlets fragment
fragment.find('*').andSelf().data('view', fragment)
fn(fragment) for fn in @postProcessingFns
fragment