Closed (outdated)
Project:
Taxonomy Term Reference Tree Widget
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 May 2014 at 12:40 UTC
Updated:
2 Dec 2025 at 14:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pryrios commentedI accidentally found why is broken in jQuery 1.9+. In fact, it shouldn't be working with any jQuery version higher than 1.6.
I needed cascade selection to work so I've been looking at it. When you have the option marked, when you click on a checkbox it fires the code and gets to:
if(event_target.attr('checked'))in fact it should be, for example:
if(event_target.is(':checked'))as explained here http://stackoverflow.com/a/8541183
Also for a more trustworthy version, in jQuery docs is remarked how to test checked properly: http://api.jquery.com/prop/
This code should work with older and newer versions of jQuery without breaking. I will try to get this script checked and submit a patch this week if I can find the time and no one beats me to it.
Comment #2
francoud commentedI just applied this simple modification and it works! Do you have any other suggestion to make it work fine in jquery 10?
Comment #3
duaelfrHere is a proper - working - patch.
Please review.
Comment #4
nicrodgersI had the same problem, first noticed when the "Track list" javascript wasn't adding items as you check them.
The patch in #3 applies cleanly to 7.x-1.x-dev, and fixes the problem. Nice one @Pyrios and @DuaelFr
Comment #5
bbcPatch #3 did the trick for me. Thanks much!
Comment #6
liquidcms commentedthis doesn't work for Boot strap as it rearranges div structure. for at least the "pick child picks parent" option i fixed by changing this:
checkbox.parents('ul.term-reference-tree-level li').children('div.form-item').children('input[type=checkbox]').each(function()to this:
checkbox.parents('ul.term-reference-tree-level li').children('div.form-item').find('input[type=checkbox]').each(function()Comment #7
duaelfr@liquidcms I Think my patch in #1976578: Undefined appears in track list when using some themes fixes the issue with Bootstrap. Could you review it, please?
Comment #8
ttkaminski commentedPatch #3 doesn't work perfectly. It works the first time the parent checkbox is checked, but if you uncheck and try again, it fails. Instead, as the OP mentioned, jquery recommends to use the prop() function to test and set the checked state. If you aren't worried about backward compatibility, change:
$(this).attr('checked', checkbox.attr('checked'));to
$(this).prop('checked', checkbox.prop('checked'));Comment #9
duaelfr@ttkaminski The thing is that prop() has been introduced in jQuery 1.6 but Drupal 7 ships with jQuery 1.4 so we absolutely need to worry about BC.
Do you think that new patch is better? Do we need to use prop() for the "disabled" attributes too?
Comment #11
ttkaminski commentedI'm all about making things simpler. Attached is a patch that doesn't rely on prop(), but rather just sets the checked property directly on the dom node. I tested with jquery 1.10, but not 1.4 (but it should work)
Comment #13
almunnings#11 works for me against 7.x-1.11
Comment #14
vladimirausThank you everyone for your contribution.
Drupal 7 is no longer supported but we always need support for Drupal 11 version.
Closing as outdated.