I find myself using this method a ton to perform actions based on a anchor tag's URL (with jQuery):
("a").live("click", function(event)
{
event.preventDefault();
var href = $(this).attr("href");
// do something with URL
}
Elsewhere in my app, I've got some tabular data which I'm adding inline edits to. When you double click a <td>
in the <table>
, it makes the data editable (text, date select, etc) and hitting "enter" will make an $.ajax
request to save the new value. My question is, if each one of these <td>
's has a href associated with it, how/where should I store the uri?
For example, a <td>
would have a URL like /articles/field/title/id/5 which I would parse using javascript and send a post using some of the params.
Is this acceptable:
<td href="/articles/field/title/id/5">
And then use the same javascript as above? Or...
- Should I add a hidden inside the ?
- Should I wrap the content in an tag inside the and make that double-clickable instead?
- Or should I use some other property?
Ideas very much welcome.