leonidas / transparency

Transparency is a semantic template engine for the browser. It maps JSON objects to DOM elements by id, class and data-bind attributes.
http://leonidas.github.com/transparency/
MIT License
969 stars 112 forks source link

Associate data object with element (when rendering lists) #17

Closed raimohanska closed 12 years ago

raimohanska commented 12 years ago

When rendering a list, I want to assign event handlers to the list item, and use the model object (list item) in those handlers.

I suggest associating the list item with the corresponding element.

Could we do that by setting a transparency.model property in the list element?

I took the first pass at this in my fork at https://github.com/raimohanska/transparency (commit 629611ab8069c6c94d198609614027ede464c32c)

This would work at least in my application code (sample below):

// find the associated naviItem from the jQuery element
var naviItem = element.get(0).transparency.model
// now do stuff with the naviItem
// ..
pyykkis commented 12 years ago

Sounds good

pyykkis commented 12 years ago

Available in master.