I've generally tried to stick with DOM-only attributes when writing Javascript. Now that I've switched from Prototype to jQuery, I can get some serious mileage out of adding my own attributes to various DOM elements, mostly in the realm of being able to set up a very readable coding convention for handling AJAX requests.
As a short example, this means I do things like
<div type="book" app_id="13">
<a href="#" action="delete">delete</a>
</div>
And then I can set up code to find all <a>
tags with an action
attribute, find a parent with a type
and app_id
, and then do CRUD operations... all without me having to write additional code.
Are there any pitfalls (other than not being strictly XHTML complaint) that I should watch out for, and/or any good habits I should look to emulate? How about a standard way of setting up my own attribute namespace?