DK
2007-Jul-11 23:37 UTC
Selectors API - problems with closing square bracket as an attribute value
I''ve got problem with the Selectors API. I want to find an element: <input type="hidden" name="a_b[c]"> All I know about it, is that this element lays inside some div with id="container", and it is not the only one hidden-type input in it. So I''ve tried to use the following call:> $$(''#container input[type=hidden][name="a_b[c]"]'')Unfortunately, it doesn''t work - finds nothing. I think, the problem may be, because of the square brackets sings used in name'' value. I''ve tried to escape them using backslash - it doesn''t work. In further investigations I''ve managed to find it using the following call:> $$(''#container input[type=hidden][name^="a_b[c"]'')This one works as expected. But what if there will be another input with name="a_b[cd]"? I don''t know what will be the names of inputs, because it''s list is generated by server-side script. I am able to workaround this, i.e. finding all the inputs of type hidden, then iterate through them and find the one with the id I''m looking for (using Enumerable.find()). But what am I curious about is where the bug lies: Is there some way I can escape the closing square bracket sign? Is it some Prototype''s selectors'' engine bug? Bad parsing rules? Maybe some browser bug? I am using Internet Explorer 6 under Win XP pro. Thanks in advance, for any replies :-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-Jul-12 16:26 UTC
Re: Selectors API - problems with closing square bracket as an attribute value
I know the square bracket notation is used in PHP, but it''s technically against spec in HTML 4+. http://www.w3.org/TR/html4/types.html#h-6.2 The trouble you''re encountering is likely something the core developers can work around, I just thought I''d point it out. TAG On Jul 11, 2007, at 5:37 PM, DK wrote:> I''ve got problem with the Selectors API. > I want to find an element: > > <input type="hidden" name="a_b[c]"> > > All I know about it, is that this element lays inside some div with > id="container", and it is not the only one hidden-type input in it. > > So I''ve tried to use the following call: >> $$(''#container input[type=hidden][name="a_b[c]"]'') > Unfortunately, it doesn''t work - finds nothing.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
DK
2007-Jul-13 19:08 UTC
Re: Selectors API - problems with closing square bracket as an attribute value
HTML4 specification page, which You have linked doesn''t refer to the "id" an"name" attributes, but it talks about SGML data types "ID" and "NAME". And allowed content for "name" is "CDATA" all over in HTML4 specs. (strange: ID is of "NAME" SGML type in html4 :-) ). Moreover... I use one of XHTML1.0 doctypes and the "NAME" type isn''t even used anywhere in it''s DTDs. The "name" attribute is of type "CDATA" too - as in html4 (btw. the type of attribute "name" of "A" element is different - it is "NMTOKEN"). But, despite of that all, I don''t think it''s the reason, why it doesn''t work. If nobody will answer me here, then I will try to write at "Core" list. Nevertheless, thanks for reply. DK --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---