jQuery: The Write Less, Do More JavaScript Library

Selector :enabled no longer finds hidden elements

View: New views
8 Messages — Rating Filter:   Alert me  

Selector :enabled no longer finds hidden elements

by Jacob-25 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


In a normal form POST, a form element with <item type="hidden"> will
send those hidden elements as request variables alongside visible
enabled variables.

In jQuery 1.3.1, filtering on $(":enabled", myForm) will only find
VISIBLE enabled elements, which is changed since jQuery 1.2.6. I don't
believe this change is correct.  Is there an explanation for this
change? Can we revert it to the earlier behavior, or is there a good
alternative?

Thanks for your time,
Jacob

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@...
To unsubscribe from this group, send email to jquery-dev+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selector :enabled no longer finds hidden elements

by Daniel Friesen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Looking at the Sizzle code:

  filters: {
    enabled: function(elem){
      return elem.disabled === false && elem.type !== "hidden";
    },
    disabled: function(elem){
      return elem.disabled === true;
    },


This honestly doesn't make sense. :not(:enabled) != :disabled and
:enabled != :not(:disabled) like it logically should be.

This will exclude any type="hidden" elements. It seams natural to
believe that $('#formid :enabled') should return any form input that
would be submitted if the form were submitted. Afact in a project at
work using the custom framework I use a selector much like that when our
.ajax call gets a form input as it's data parameter (ie: It goes through
the enabled inputs and extracts the value of all the named ones and
converts it into the urlencoded data string).

~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://nadir-seen-fire.com]
-Nadir-Point (http://nadir-point.com)
-Wiki-Tools (http://wiki-tools.com)
-MonkeyScript (http://monkeyscript.nadir-point.com)
-Animepedia (http://anime.wikia.com)
-Narutopedia (http://naruto.wikia.com)
-Soul Eater Wiki (http://souleater.wikia.com)



Jacob wrote:

> In a normal form POST, a form element with <item type="hidden"> will
> send those hidden elements as request variables alongside visible
> enabled variables.
>
> In jQuery 1.3.1, filtering on $(":enabled", myForm) will only find
> VISIBLE enabled elements, which is changed since jQuery 1.2.6. I don't
> believe this change is correct.  Is there an explanation for this
> change? Can we revert it to the earlier behavior, or is there a good
> alternative?
>
> Thanks for your time,
> Jacob
>
> >
>  

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@...
To unsubscribe from this group, send email to jquery-dev+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selector :enabled no longer finds hidden elements

by Diego Perini :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Daniel,
this is how I see these attributes on form elements:

"enabled"
the functionalities of the form element are available and interactions
by users are allowed

"disabled"
the functionalities of the form element are available and interactions
by users are disallowed

"hidden"
the form element is not rendered by the UI and can only be modified
programmatically

None of them specify if the field would be submitted or not, if I
recall correctly all of the form elements values should be serialized
and submitted, "enabled", "disabled" and "hidden". Differing
implementations are framework specific and most probably not done
through a standard form submission but through an Ajax request
instead.

Diego


On 29 Gen, 21:03, Daniel Friesen <nadir.seen.f...@...> wrote:

> Looking at the Sizzle code:
>
>   filters: {
>     enabled: function(elem){
>       return elem.disabled === false && elem.type !== "hidden";
>     },
>     disabled: function(elem){
>       return elem.disabled === true;
>     },
>
> This honestly doesn't make sense. :not(:enabled) != :disabled and
> :enabled != :not(:disabled) like it logically should be.
>
> This will exclude any type="hidden" elements. It seams natural to
> believe that $('#formid :enabled') should return any form input that
> would be submitted if the form were submitted. Afact in a project at
> work using the custom framework I use a selector much like that when our
> .ajax call gets a form input as it's data parameter (ie: It goes through
> the enabled inputs and extracts the value of all the named ones and
> converts it into the urlencoded data string).
>
> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://nadir-seen-fire.com]
> -Nadir-Point (http://nadir-point.com)
> -Wiki-Tools (http://wiki-tools.com)
> -MonkeyScript (http://monkeyscript.nadir-point.com)
> -Animepedia (http://anime.wikia.com)
> -Narutopedia (http://naruto.wikia.com)
> -Soul Eater Wiki (http://souleater.wikia.com)
>
> Jacob wrote:
> > In a normal form POST, a form element with <item type="hidden"> will
> > send those hidden elements as request variables alongside visible
> > enabled variables.
>
> > In jQuery 1.3.1, filtering on $(":enabled", myForm) will only find
> > VISIBLE enabled elements, which is changed since jQuery 1.2.6. I don't
> > believe this change is correct.  Is there an explanation for this
> > change? Can we revert it to the earlier behavior, or is there a good
> > alternative?
>
> > Thanks for your time,
> > Jacob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@...
To unsubscribe from this group, send email to jquery-dev+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selector :enabled no longer finds hidden elements

by John Resig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Jacob -

We made this change to become more standards compliant (the browsers
that supported querySelectorAll interpreted :enabled in this manner -
assuming that a hidden element was always not enabled).

--John



On Thu, Jan 29, 2009 at 10:48 AM, Jacob <pinano@...> wrote:

>
> In a normal form POST, a form element with <item type="hidden"> will
> send those hidden elements as request variables alongside visible
> enabled variables.
>
> In jQuery 1.3.1, filtering on $(":enabled", myForm) will only find
> VISIBLE enabled elements, which is changed since jQuery 1.2.6. I don't
> believe this change is correct.  Is there an explanation for this
> change? Can we revert it to the earlier behavior, or is there a good
> alternative?
>
> Thanks for your time,
> Jacob
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@...
To unsubscribe from this group, send email to jquery-dev+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selector :enabled no longer finds hidden elements

by Matt Kruse-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jan 29, 3:50 pm, Diego Perini <diego.per...@...> wrote:
> None of them specify if the field would be submitted or not, if I
> recall correctly all of the form elements values should be serialized
> and submitted, "enabled", "disabled" and "hidden".

Disabled form elements are not submitted.

Matt Kruse

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@...
To unsubscribe from this group, send email to jquery-dev+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selector :enabled no longer finds hidden elements

by Diego Perini :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Matt,
I didn't recall correctly....too late in the night one can dream
whatever...

Thank you for reminding me and adjusting my wrong assertion.

Diego


On 30 Gen, 17:49, Matt <m...@...> wrote:
> On Jan 29, 3:50 pm, Diego Perini <diego.per...@...> wrote:
>
> > None of them specify if the field would be submitted or not, if I
> > recall correctly all of the form elements values should be serialized
> > and submitted, "enabled", "disabled" and "hidden".
>
> Disabled form elements are not submitted.
>
> Matt Kruse
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@...
To unsubscribe from this group, send email to jquery-dev+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selector :enabled no longer finds hidden elements

by Keith Winkler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


That is confusing.

The documentation currently says just "Matches all elements that are
enabled."

At the very least we should amend the documents, else this will be a
source of pain for many.

What is the behavior of ":disabled",  Does it select enabled inputs
that are hidden?

Cheers

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@...
To unsubscribe from this group, send email to jquery-dev+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selector :enabled no longer finds hidden elements

by Keith Winkler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


It appears that (testing 1.3.1) ":disabled" selects disabled form
elements, regardless of if they are hidden.  As one would expect
(based on intuition and current jQuery docs).

The result is that ":disabled" is NOT the complement of enabled.

":disabled"  -- select elements that are disabled
":enabled" -- select elements that are enabled, but not of type
"hidden".  However it DOES select elements hidden via
style="display:none"

That this is the behavior is not at all clear from the docs.

For reference, from the HTML 4 spec:

"DISABLED attribute, also new in HTML 4.0, disables the control.
Disabled elements are read-only elements with the added restrictions
that the values are not submitted with the form, the elements cannot
receive focus, and the elements are skipped when navigating the
document by tabbing."

Perhaps the most intuitive behavior would be if the ":enabled",
":disabled" selectors selected elements directly corresponding to
whether the disabled attribute is set, and nothing more.


Cheers (thanks for you hard work jQuery devs)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Development" group.
To post to this group, send email to jquery-dev@...
To unsubscribe from this group, send email to jquery-dev+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---