Using jQuery and backbone.js, I would like to separate the JavaScript from the HTML as much as possible.
Is it possible to add a custom attribute for a better separation between JavaScript and HTML?
And then how can I use the new jQuery selector?
Example:
<input type="text" id="todo-input" class="todo-input" tid="tid-attribute" > hello world </input>
// The DOM events
// I would like to use another selector tid and not class or id
events: {
"keypress #todo-input" : "updateOnEnter" // I would like to use another selector tid not id,
"keypress .todo-input" : "updateOnEnter" // I would like to use another selector tid and not class
}
classattributes are used for all sorts of things, not just for styling with CSS. There's nothing wrong with adding extra classes to an element just for use in selectors.