SPServices Still using jQuery .attr(), instead of .prop() to change values

Dec 13, 2011 at 11:22 PM
Edited Dec 13, 2011 at 11:29 PM

Marc,

This is to make you aware of a problem I encountered with setting the "Checked" attribute on checkboxe's after upgrading to jQuery 1.6...

With the introduction of jQuery's .prop() method (v1.6), using .attr() to set the checked property on a checkbox no longer works reliably.  Looks like the value of an attribute is only used when it first load it into DOM... from that point forward it is considered a property and change to the attribute value are no longer reflected.

While checking my code, I noticed several instances in SPServices (I'm running 0.6.2) where you seem to be doing the same thing. I personally have not encountered any issue with your use of it, but figure I would pass along this information.

Note that so far, I have only found a problem when setting the "checked" value of a checkbox input... The problem may be there when trying to update other attributes.

From the jQuery api for .prop():

"The .prop() method should be used to set disabled and checked instead of the .attr() method. The .val() method should be used for getting and setting value."

 

Paul.