[jQuery] Re: input field name include . jquery cann't parse

2009-05-28 Thread Ricardo

It's not that hard to create a function that escapes special
characters in case you need it. It's the same issue as with CSS,
jQuery can't escape anything automatically because it can't guess what
you're after.

On May 27, 8:09 pm, RobG rg...@iinet.net.au wrote:
 On May 28, 4:07 am, Karl Swedberg k...@englishrules.com wrote:

  On May 26, 2009, at 9:05 PM, RobG wrote:

   The choice is clear - the OP can simply stop using jQuery selectors
   for those elements, or stop using jQuery (or any other CSS selector-
   based framework) at all.

  Really? That's the only choice? As others have already noted, you can
  simply escape the .

 Which infers simply hard coding all such IDs in the script, not a
 sustainable strategy in a non-trivial application where the ID is
 likely more efficiently passed as a parameter and therefore not a
 viable option IMO.  The solution below doesn't require any hard coding
 and conforms to the first choice proposed above.

 http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_...

 Yes, we've seen that earlier in the thread.  I commented on it.

   Given that it's an ID, the OP could use:

    $(document.getElementById('user.name'))...

   Which is likely faster anyway.

  True, but the speed difference is likely negligible.

 The comment about speed is primarily to indicate that it won't be
 slower, so the option of quoting the period character has nothing to
 recommend it.  The OP is, of course, free to chose whatever option
 suits.

   The jQuery
   documentation does, after all, refer to them as weird and special
   characters.

  If you think there is more appropriate terminology, feel free to
  change it. The documentation site is a wiki.

 I'd rather let it stand.  It reflects the attitude of the author and
 seems to have the support of at two posters here.

 --
 Rob


[jQuery] Re: input field name include . jquery cann't parse

2009-05-27 Thread Karl Swedberg


On May 26, 2009, at 9:05 PM, RobG wrote:


The choice is clear - the OP can simply stop using jQuery selectors
for those elements, or stop using jQuery (or any other CSS selector-
based framework) at all.


Really? That's the only choice? As others have already noted, you can  
simply escape the .


http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_element_that_has_weird_characters_in_its_ID.3F


Given that it's an ID, the OP could use:

 $(document.getElementById('user.name'))...

Which is likely faster anyway.


True, but the speed difference is likely negligible.


The jQuery
documentation does, after all, refer to them as weird and special
characters.



If you think there is more appropriate terminology, feel free to  
change it. The documentation site is a wiki.



--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com



[jQuery] Re: input field name include . jquery cann't parse

2009-05-27 Thread RobG



On May 28, 4:07 am, Karl Swedberg k...@englishrules.com wrote:
 On May 26, 2009, at 9:05 PM, RobG wrote:

  The choice is clear - the OP can simply stop using jQuery selectors
  for those elements, or stop using jQuery (or any other CSS selector-
  based framework) at all.

 Really? That's the only choice? As others have already noted, you can
 simply escape the .

Which infers simply hard coding all such IDs in the script, not a
sustainable strategy in a non-trivial application where the ID is
likely more efficiently passed as a parameter and therefore not a
viable option IMO.  The solution below doesn't require any hard coding
and conforms to the first choice proposed above.


 http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_...

Yes, we've seen that earlier in the thread.  I commented on it.


  Given that it's an ID, the OP could use:

   $(document.getElementById('user.name'))...

  Which is likely faster anyway.

 True, but the speed difference is likely negligible.

The comment about speed is primarily to indicate that it won't be
slower, so the option of quoting the period character has nothing to
recommend it.  The OP is, of course, free to chose whatever option
suits.


  The jQuery
  documentation does, after all, refer to them as weird and special
  characters.

 If you think there is more appropriate terminology, feel free to
 change it. The documentation site is a wiki.


I'd rather let it stand.  It reflects the attitude of the author and
seems to have the support of at two posters here.


--
Rob


[jQuery] Re: input field name include . jquery cann't parse

2009-05-27 Thread MorningZ

I know i wouldn't call them weird, but i would for sure classify
using something like user.name as *problematic* or even unnecessary
pain in the a__ as a programmer living and dying by jQuery, lol...

whatever though... to each their own  that's the beauty of this
field of work  :-)





On May 27, 7:09 pm, RobG rg...@iinet.net.au wrote:
 On May 28, 4:07 am, Karl Swedberg k...@englishrules.com wrote:

  On May 26, 2009, at 9:05 PM, RobG wrote:

   The choice is clear - the OP can simply stop using jQuery selectors
   for those elements, or stop using jQuery (or any other CSS selector-
   based framework) at all.

  Really? That's the only choice? As others have already noted, you can
  simply escape the .

 Which infers simply hard coding all such IDs in the script, not a
 sustainable strategy in a non-trivial application where the ID is
 likely more efficiently passed as a parameter and therefore not a
 viable option IMO.  The solution below doesn't require any hard coding
 and conforms to the first choice proposed above.

 http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_...

 Yes, we've seen that earlier in the thread.  I commented on it.

   Given that it's an ID, the OP could use:

    $(document.getElementById('user.name'))...

   Which is likely faster anyway.

  True, but the speed difference is likely negligible.

 The comment about speed is primarily to indicate that it won't be
 slower, so the option of quoting the period character has nothing to
 recommend it.  The OP is, of course, free to chose whatever option
 suits.

   The jQuery
   documentation does, after all, refer to them as weird and special
   characters.

  If you think there is more appropriate terminology, feel free to
  change it. The documentation site is a wiki.

 I'd rather let it stand.  It reflects the attitude of the author and
 seems to have the support of at two posters here.

 --
 Rob


[jQuery] Re: input field name include . jquery cann't parse

2009-05-27 Thread Dave Methvin

The HTML spec allows characters in ids that the CSS selector spec
(used by jQuery) requires to be escaped. Is there some solution that
has been overlooked by jQuery and the W3C?

http://www.w3.org/TR/2009/CR-CSS2-20090423/syndata.html#characters

In CSS, identifiers  (including element names, classes, and IDs in
selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646
characters U+00A1 and higher, plus the hyphen (-) and the underscore
(_); they cannot start with a digit, or a hyphen followed by a digit.
Identifiers can also contain escaped characters and any ISO 10646
character as a numeric code (see next item). For instance, the
identifier BW? may be written as B\W\? or B\26 W\3F.


[jQuery] Re: input field name include . jquery cann't parse

2009-05-26 Thread donb

'# 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 (.).'

http://www.w3.org/TR/html401/types.html#type-name

So it would seem to be a bug.

On May 26, 4:09 am, weit...@263.net weit...@263.net wrote:
 when i use jquery get a input like
 input type=text id=user.name name=user.name/

 use $(#user.name) is error

 if input is
 input type=text id=username name=username/
 use $(#username) is right

 is bug?


[jQuery] Re: input field name include . jquery cann't parse

2009-05-26 Thread Juan Liu
这个有人清楚么?我也比较好奇


[jQuery] Re: input field name include . jquery cann't parse

2009-05-26 Thread MorningZ

No, it's not a bug, your selector is looking for an item of class
name... so it's your selector that is the issue, not jQuery  (your
naming/id convention would also cause issues with CSS)...

If you insist on poor choices for naming your controls, it is still
possible to select the items though

http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_element_that_has_weird_characters_in_its_ID.3F


On May 26, 4:09 am, weit...@263.net weit...@263.net wrote:
 when i use jquery get a input like
 input type=text id=user.name name=user.name/

 use $(#user.name) is error

 if input is
 input type=text id=username name=username/
 use $(#username) is right

 is bug?


[jQuery] Re: input field name include . jquery cann't parse

2009-05-26 Thread Ricardo

Poor choices is relative. I'd love a way to use colons in IDs
avoiding the confusion with pseudo-selectors, kind of like namespacing
elements. If it's in the specs it's perfectly valid.

On May 26, 9:17 am, MorningZ morni...@gmail.com wrote:
 No, it's not a bug, your selector is looking for an item of class
 name... so it's your selector that is the issue, not jQuery  (your
 naming/id convention would also cause issues with CSS)...

 If you insist on poor choices for naming your controls, it is still
 possible to select the items though

 http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_...

 On May 26, 4:09 am, weit...@263.net weit...@263.net wrote:

  when i use jquery get a input like
  input type=text id=user.name name=user.name/

  use $(#user.name) is error

  if input is
  input type=text id=username name=username/
  use $(#username) is right

  is bug?


[jQuery] Re: input field name include . jquery cann't parse

2009-05-26 Thread MorningZ

So if you had:

input type=text id=user.name /

how would you apply a style to that?

can't say:

#user.name {

}

because that would look for

input type=text id=user class=name /

yeah, poor choice sure is relative, but why make things more
difficult, when a simple dash or underscore would do the same thing
(and not cause issues with basic CSS or jQuery)






On May 26, 3:03 pm, Ricardo ricardob...@gmail.com wrote:
 Poor choices is relative. I'd love a way to use colons in IDs
 avoiding the confusion with pseudo-selectors, kind of like namespacing
 elements. If it's in the specs it's perfectly valid.

 On May 26, 9:17 am, MorningZ morni...@gmail.com wrote:

  No, it's not a bug, your selector is looking for an item of class
  name... so it's your selector that is the issue, not jQuery  (your
  naming/id convention would also cause issues with CSS)...

  If you insist on poor choices for naming your controls, it is still
  possible to select the items though

 http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_...

  On May 26, 4:09 am, weit...@263.net weit...@263.net wrote:

   when i use jquery get a input like
   input type=text id=user.name name=user.name/

   use $(#user.name) is error

   if input is
   input type=text id=username name=username/
   use $(#username) is right

   is bug?


[jQuery] Re: input field name include . jquery cann't parse

2009-05-26 Thread James

$(#user\\.name)
seems to work in FF3. Haven't tried in other browsers.

On May 25, 10:09 pm, weit...@263.net weit...@263.net wrote:
 when i use jquery get a input like
 input type=text id=user.name name=user.name/

 use $(#user.name) is error

 if input is
 input type=text id=username name=username/
 use $(#username) is right

 is bug?


[jQuery] Re: input field name include . jquery cann't parse

2009-05-26 Thread RobG



On May 27, 6:21 am, MorningZ morni...@gmail.com wrote:
 So if you had:

 input type=text id=user.name /

 how would you apply a style to that?

Using a class or a selector other than the id.


 can't say:

 #user.name {
 }

 because that would look for

 input type=text id=user class=name /

 yeah, poor choice sure is relative, but why make things more
 difficult, when a simple dash or underscore would do the same thing
 (and not cause issues with basic CSS or jQuery)

The choice is clear - the OP can simply stop using jQuery selectors
for those elements, or stop using jQuery (or any other CSS selector-
based framework) at all.  Given that it's an ID, the OP could use:

  $(document.getElementById('user.name'))...

Which is likely faster anyway.

There is conflict between what is allowed as a value of the ID
attribute and what CSS can use to select elements by ID.  It remains
an issue for anyone wishing to select elements using CSS selectors,
regardless of the context.

It is also an issue with the W3C Selectors API, a specification to
which John Resig (and many others) contributed, yet there is nothing
within that specification to address the issue raised in this thread.
Clearly they don't think it's worth addressing.  The jQuery
documentation does, after all, refer to them as weird and special
characters.


--
Rob