[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-12 Thread Dave Stewart
I knew about :input, but my brain just pre-supposed it meant only input elements so I had kind of disregarded them somewhat. So thanks for pointing that out!

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-11 Thread Aaron Heimlich
On Feb 11, 2008 10:07 AM, Dave Stewart [EMAIL PROTECTED] wrote: Hi Aaron, Good styles there with the name attribute stuff. Not so good if you want to grab other entities such as selects This should select any form element (input,select,textarea,button) whose name attribute is foo[bar][baz]:

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-11 Thread Dave Stewart
Hey Marty, I couldn't live without PHP's square brackets. I just about always want to split up a form into component parts. I could easily write something using RegExp to do this for me, but having it all built in is just lovely. Great that Rails has it too. Cheers, Dave

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-11 Thread Dave Stewart
Hi Aaron, Good styles there with the name attribute stuff. Not so good if you want to grab other entities such as selects, but good to see that it accepts non-standard characters.

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-08 Thread Marty Vance
All Browsers assign form data variable names according to the name attribute, not id. PHP uses square brackets as a shortcut to automagically build arrays from the request data. Like Karl said, this is illegal in HTML, and still seems not allowed in XHTML according to

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-08 Thread Aaron Heimlich
Actually, according to the HTML 4.01 spec, the name attribute on input elements[1] is defined as being of type CDATA[2], which is very permissive in the kinds of characters it allows. There is a section in the XHTML 1.0spec that talks about restricting the allowed characters in the name

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-08 Thread Ken Gregg
Pre jquery I have used an id without the square brackets and a name with the square brackets. I used the id in my javascript and the form would submit with the name. Ken On Feb 7, 6:28 am, Dave Stewart [EMAIL PROTECTED] wrote: I'm finding it impossible using jQuery to select any attributes

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-08 Thread Dave Stewart
OK - this is the best I could come up: function $$(selector, context){ return jQuery(selector.replace(/(\[|\])/g, '\\$1'), context) } $$('#contact[email]') It adds to the global namespace (so won't work with prototype for example, which also uses

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-07 Thread Karl Rudd
You can use square brackets, you just have to put a '\' before them (which has to be done as '\\' because of JavaScript's encoding) http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_element_that_has_weird_characters_in_its_ID.3F Karl On Feb 8, 2008 1:28 AM, Dave Stewart

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-07 Thread Dave Stewart
Wow, that's really useful to know, thanks Karl. I think I'll just use a regular expression: selector = selector.replace(/(\[|\])/g, '\$1') It would be really useful if this were an option, somehow. My jQuery- foo is not all that. Any ideas, anyone? Cheers, Dave

[jQuery] Re: jQuery won't recognise attribute names containing [square brackets]

2008-02-07 Thread Karl Rudd
Remember also that technically in HTML id and name attributes can't contain '[]'s. ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (-), underscores (_), colons (:), and periods (.). -