[Catalyst] Re: HTML::FormHandler IDs not playing with JQuery

Aristotle Pagaltzis pagaltzis at gmx.de
Fri Apr 1 14:09:29 GMT 2011


* Dmitry L. <dim0xff at gmail.com> [2011-03-29 18:20]:
> > http://api.jquery.com/category/selectors/
> >
> >   If you wish to use any of the meta-characters ( such as
> >   !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, you must
> >   escape the character with two backslashes: \\. For example, if you
> >   have an an element with id="foo.bar", you can use the selector
> >   $("#foo\\.bar").
> >
> or do something like this:
>
> $('[id="foo.bar"]')

But note that this is much, much slower than an actual ID search,
which compiles down to a single `getElementById` call.

And note also that the quotes around the value are not actually
allowed per CSS spec, and recent jQuery versions have been
updated to follow the spec on this point.

So in this case it’s really preferable to use something like

    $( '#' + elt_id.replace( /\./, '\\.' ) )

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Catalyst mailing list