I often find myself providing some sort of naming convention for stickit
jQuery target ID
s, in the form some-aggregate-individual-element-{#number}
pairing each ID
with a corresponding collection element in a one-to-one fashion. This is to ensure that stickit
will update only the particular View
in question and not other similar aggregate views.
It seems like there should be a way to use, say, class names rather than ID
s for this purpose if you could somehow tell stickit
the "root" node to perform updates under. For instance, if I am defining a View
and I say bindings: { ".individual-title": { observe: "Title" } }
, stickit
knows that the Title
attribute is coming from this.model
so there is no need for qualification. However, whenever I apply the same logic to the left hand side, stickit
performs updates against ALL nodes on the document with that class name rather than only those nodes that live under this.$el
, where $el
is the root node of my view.
Is there a built-in or otherwise easy way to achieve this so I can stop id
ing all of my elements with silly naming conventions? Or is this what you are supposed to be doing?
I actually bind to the name attribute on on the form element, therefore eliminating the use of ids and classnames. So for example lets say I have the following model.
I then create the following helpers:
Then we can have the following view:
Initialize our view
It would then bind to your template with the the following inputs: