Problem/Motivation
In upgrading a site to use a release of jQuery newer than 1.5, the dependent checkbox code fails with a trigger value of one or true. This is because, in the ctools 1.2 release (used on the site), the dependent.js code uses the attr()
function as the value of this property in:
var val = $(trigger).attr('checked') || 0;
which changed from returning true to 'checked' with the 1.6 release. This code changed in the ctools 1.3 release to:
var val = $(trigger).attr('checked') ? true : false;
Per the jQuery documentation, the property value is the preferred item to use with a checkbox element. The return value of prop()
did not change with the 1.6 release.
Proposed resolution
Use the prop()
function in dependent.js to determine whether the element is checked. Given the change in the 1.3 release (for returning true or false, and not 'checked' or 0 which would be the case without the change shown above), the current proposed change should have no adverse consequences on existing code. Any site using the 1.2 release of dependent.js with a 1.6+ release of jQuery would have had to modify its code to use a trigger value of 'checked' to deal with the change in return value, and would have to revert it with the next release of ctools.
Remaining tasks
Review, test, document.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#5 | ctools-use_prop_instead_of_attr-2353853-5.patch | 2.84 KB | tien.xuan.vo |
#3 | 2353853-use-prop-instead-of-attr.patch | 870 bytes | solotandem |
Comments
Comment #1
solotandem CreditAttribution: solotandem commentedComment #2
solotandem CreditAttribution: solotandem commentedComment #3
solotandem CreditAttribution: solotandem commentedAttached patch implements proposed resolution.
Comment #4
solotandem CreditAttribution: solotandem commentedComment #5
tien.xuan.vo CreditAttribution: tien.xuan.vo commented#1494860-3: Views Rewrite Results UI Broken using JQuery 1.7 Already has a patch that work well for me, but it is not committed. I have re-rolled the patch.
Comment #6
solotandem CreditAttribution: solotandem commentedIf you are rerolling a patch on another issue, then why not post it on that issue?
Comment #7
tien.xuan.vo CreditAttribution: tien.xuan.vo commentedI thought about that, but that issue is fixed and committed. This is a issue related to that issue, so I think here is the best place to upload the patch.
Comment #9
andeersg CreditAttribution: andeersg commentedI can verify that the patch in #5 works, tested it with CTools 7.x-1.9 and Panels 7.x-3.5 (Tested the panel pane override title form).
Comment #10
IRuslan CreditAttribution: IRuslan as a volunteer and at DrupalJedi commentedAlso works for me.
Tested with jQuery 1.10.
Comment #11
MustangGB CreditAttribution: MustangGB commentedWorks great with jQuery 2.1
Comment #12
japerryThanks for the patch!
This tested out for me in both stock jquery as well as an updated (1.10) version. Committed.