Some modules require that I use jQuery 1.10

If jQuery is set to 1.9 or 1.10 the select functions break.

Comments

pryrios’s picture

I 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.

francoud’s picture

I just applied this simple modification and it works! Do you have any other suggestion to make it work fine in jquery 10?

duaelfr’s picture

Version: 7.x-1.10 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.75 KB

Here is a proper - working - patch.
Please review.

nicrodgers’s picture

Status: Needs review » Reviewed & tested by the community

I 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

bbc’s picture

Patch #3 did the trick for me. Thanks much!

liquidcms’s picture

this 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()

duaelfr’s picture

@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?

ttkaminski’s picture

Status: Reviewed & tested by the community » Needs work

Patch #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'));

duaelfr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.09 KB
new2.26 KB

@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?

Status: Needs review » Needs work

The last submitted patch, 9: term_reference_tree-fix_jquery_1.9%2B-2271719-9.patch, failed testing.

ttkaminski’s picture

Status: Needs work » Needs review
StatusFileSize
new2.05 KB

I'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)

Status: Needs review » Needs work

The last submitted patch, 11: term_reference_tree-fix_jquery_1.9-2271719-11.patch, failed testing.

almunnings’s picture

#11 works for me against 7.x-1.11

vladimiraus’s picture

Status: Needs work » Closed (outdated)

Thank you everyone for your contribution.
Drupal 7 is no longer supported but we always need support for Drupal 11 version.
Closing as outdated.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.