This is the next question for. In jQuery, is it a bad idea to use name = X for all selectors?
I use Backbone and decided that I needed a way to distinguish between HTML elements that were connected and those that were not.
So I would write (in HAML):
.container .title(name='title') .separator
As you can see, itβs clear that the dynamic element is the title.
The reason for this was that I could mess around with the style and rename the classes without worrying about breaking the application. It also means that in the template, I can say that dynamic elements do not need to go back and forth with the Backbone View.
Now my question is: without using the [name] selector, does anyone have a code legend to keep track of which HTML elements are referencing JS .
I am considering:
- Use a common prefix for class names (e.g.
class=bind-title ) - Using some kind of custom HTML element (
Thanks!
FYI: I use CoffeeScript, Backbone and haml_coffee templates.
Updated jsperf to check all offers:
http://jsperf.com/class-or-name-attr-lookup/3
source share