I was using custom attributes, I just discovered that when using live
() to bind events to HTML elements coming in via AJAX would
mysteriously stop working. I searched around the bugs DB and found
that it was the custom attributes I was using to select the elements
to bind to that was causing things to stop working. I removed the
custom attributes and use a class instead and it started working
again.

So now I will be removing all the custom attributes.


On Apr 14, 1:56 pm, seasoup <seas...@gmail.com> wrote:
> I was wondering what jquery developers opinion of adding custom
> attributes to html tags is, and what your basis is for these
> opinions?  Why is it a good idea, or why is it a bad idea?  What I
> mean is this:
>
> <div href="" myType="foo">content</div>
>
> where 'myType' isn't in any specifications.  I've run into developers
> who think this is a good idea, and those who think this is a bad idea
> and I'd like to get a better sense of both sides of the argument.
> Personally, I use them all of the time.  They are a great way to
> preserve information for use with .live() in jQuery, among other
> things, and since I append a long string to the DOM instead of
> creating lots of little DOM nodes, I generally cannot use .data() to
> save information on the individual nodes.
>
> Example of a usage:
>
> <div name="foo" myType="bar">click</div>
> ...
> $('div[name=foo]').live('click', function () {
>    console.log($(this).attr('myType'));
>
> });
>
> Example of why I cannot use .data():
>
> var htmlString = '<table>';
> for (var a = 0; a < 100; a++) {
>     htmlString += '<tr><td name="clickme" nodeId="filter'+ a
> +'">click</td></tr>';}
>
> htmlString += '</table>';
> $('div[name=foo]').append(htmlString);
> $('td[name=clickme]').live('click', function() {
>     console.log($(this).attr('nodeId'));
>
> });
>
> To debate the merits of using this kind of append, please go 
> to:http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-cor...
>
> What I'm looking for instead is a discussion of using custom
> attributes in html.
>
> Thanks,
> Josh Powell

Reply via email to