I find a lot of situations where I'd like to attach a variable to a div or another HTML element. For example, I have a div that I'm using as a dialog window to edit a row in a table - something like this:
<div class='dialog' id='editTableLineDialog'/>
When this dialog opens, I need to record the id of the line in the table I'm editing. In the past I've created global variables called lineCurrentlyEditting (Yuck!) or I've embedded the id in the actual table id like such:
<div class='dialog' id='editTableLineDialog_43'/>
Neither solution is very elegant. I'd like to be able to just add the variable to the div, like such:
var dialog = document.getElementById('editTableLineDialog');
dialog.tableLineId = 43;
or
$('#editTableLineDialog').tableLineId = 43;
or
<div meta='{tableLineId=43}' class='dialog' id='editTableLineDialog'/>
Is there anyway to do something like this? What's the best way to handle a situation like this? Does JQuery have a solution?