I'm not sure if this is a bug in this module or somewhere else but:

After clearing caches everything works fine for a couple of page loads, then the widget flippers (no fixed pattern) a couple of times to end on closed or open position. This in combination with the professional theme.

CommentFileSizeAuthor
#6 term_reference_tree-use-once.patch761 byteskoechsle

Comments

troybthompson’s picture

I haven't seen this myself, but users of the site have been reporting something similar. I've used the same browsers as them and can't replicate it.

guerno’s picture

The browser does not matter. I tested this in all major browsers. Firefox, Chrome, Explorer, Safari. All had the same issue.

guerno’s picture

An update on this: I think it's a bug in drupal itself. I did some adjustments in the includes/ajax.inc. Applied some patches to correct other ajax errors that views was outputting and now the taxonomy tree select also seems to work fine by accident :D.

The stupid thing of me: I just tried some patches (3 or so) and can't remember which ones. But it where patches on the includes/ajax.inc to correct error:500's in views.

My drupal version is 7.21

rob230’s picture

I'm having this problem as well. It is difficult to track the cause because it works fine at first. It seems like if I leave the page open in my browser for a long time, eventually it'll happen, but I don't have the patience to find a reproducible cause. At first it'll be fine, then it might open and close a couple of times, and eventually it'll be opening and closing a dozen times.

FaberfoX’s picture

In my case, after uploading an image to a field, no matter if it's before or after the tree, the expand/collapse buttons behave as if clicked twice.
Removing the image or adding a new one makes it behave as if clicked 3 times, and so on.
This happens using either throbber or progress bar for the image upload.
My knowledge is limited but something similar happened to me here and I solved it in a dirty way (creating a page variable and checking for it's existence to stop attaching the click function).
If someone can confirm this finding, I'll try to look into the code to create a patch, I guess if my assumption is correct, it should be an easy fix to those who know a bit more than me.

koechsle’s picture

StatusFileSize
new761 bytes

The problem is the .attach() function is called again when there is an Ajax event - this attaches the jquery click() handler to the expand/collapse buttons AGAIN. So after that, the expand/collapse click handler is called twice.
I am pretty sure this is also the cause for this Taxonomy Manager issue :
Incompatibility with Term Reference Tree Module

Here Managing JavaScript in Drupal 7 I read that you should use jquery once to circumvent this problem.
I have made a simple fix by adding once() as a filter before the click():

term_reference_tree.js line 5:
$('.term-reference-tree-button', context).once().click(function() { // once() used to avoid the click handler being attached multiple times (otherwise attach is called for each AJAX refresh)

This is whats in the patch.

dave reid’s picture

Status: Active » Closed (duplicate)
giufog’s picture

anche a me lo stesso problema, dipendeva da hierarchical select, disinstallato e ora tutto ok

guerno’s picture

#6 works fine, thanks!