Side navigation
#9927 closed bug (invalid)
Opened July 28, 2011 04:03AM UTC
Closed July 28, 2011 10:49AM UTC
Last modified March 09, 2012 05:58PM UTC
$("select").attr("disabled", ""); does not work anymore
Reported by: | giovanni.g@gmail.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | attributes | Version: | 1.6.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
greetings, i upgraded from JQuery 1.4 to 1.6 and i noticed a change in behaviour of $foo.attr("disabled", "");
before it was working, now i had to replace it with $foo.removeAttr("disabled"), anyway i don't see any good explanation for this "new behaviour".
regards
Attachments (0)
Change History (7)
Changed July 28, 2011 10:49AM UTC by comment:1
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
resolution: | → invalid |
status: | new → closed |
Changed August 11, 2011 08:17PM UTC by comment:2
Why was this marked invalid?
From[BLOG » JQUERY 1.6.1 RELEASED|http://blog.jquery.com/2011/05/12/jquery-1-6-1-released/]:
''Specifically, boolean attributes such as checked, selected, readonly, and disabled in 1.6.1 will be treated just as they used to be treated in jQuery versions prior to 1.6.''
It seems the blog is saying one thing and you are saying something completely different. I understand the "preferred" or "desired" methods, but at the same time, if the blog says "this will work the way it always has", well, then, I sort of expect it to.....will work the way it always has.
Changed August 15, 2011 08:36PM UTC by comment:3
If the caller had used true
or false
then it would work, since that's the way many people used to do it -- treating the attribute like a property. The use of a boolean value is a clue that they want the old behavior, since only strings are valid attribute values.
Thanks for submitting a ticket!. In jQuery 1.6, a significant change was made to the way we handle getters and setters for attributes and as a part of this we introduced the idea of .prop() for accessing properties.
If you are using jQuery < 1.6 do this:
$foo.attr("disabled", value);
If you are using jQuery 1.6+:
$foo.prop("disabled", value); (eg. where value is true)
If you require more information about the differences between .prop() and .attr() you may find the following stackoverflow post useful: http://stackoverflow.com/questions/5874652/prop-vs-attr