maccman/spine — Issue #188: Spine.List depends on some strange hem behaviour
Author: iblue
Created: 2012-01-23 03:12:56+00:00
State: open

Hi,

After I have been playing with spine and it's rails integration for a while and after about 12 hours of single stepping through the code I found out, that Spine.List depends on a strange behaviour the hem precompiler has - which of coure is not available in rails. The hem precompiler assigns the supplied data via jQuery.data to the rendered object (see line 34 https://github.com/maccman/hem/blob/master/src/compilers.coffee). This is very useful. If I catch a click event, I just call `$(the_target_of_the_event).data("whatever_value_i_want")` and I get the data, that has been used to render the stuff. No more fiddling with data-index and friends. Hooray!

Spine.List uses this. It calls some helper function that can be added to jQuery (see line 7, https://github.com/maccman/spine/blob/master/src/tmpl.coffee). And this is, where the problems start.

The rails asset precompilers do assign additional data to the rendered DOM. Probably because, this would make the code dependent on jQuery. So Spine.List is not compatible with the rails implementation. Neither with the eco gem, nor with haml_coffee_assets (which I use).

It's 4 AM in Germany and I know spine since two days, otherwise I would have probably fixed this myself, either in spine or in eco and haml_coffee_assets. But I think this is relying on undocumented features and therefore a bug.

Thank you all for working on spine - I appreciate it!

Good night!
Markus