Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi,
I'm trying to use the add-to-dropbox events but it doesn't seem work or maybe I not using it correctly .
$('#hierarchical-select-0-wrapper').bind('add-to-dropbox', function() {
alert('add to dropbox');
});
nothing happens...
I noticed that if I use before-add-to-dropbox, it works only if I selected any items. If I select one it stops to work.
What i would like to do, exactly, is to call an ajax_form_callback like simple select
$form['voc_1'] = array(
'#type' => 'select',
'#title' => t('Voc 1'),
'#options' => $term_array ,
'#ajax' => array(
'callback' => 'ajax_form_callback',
'wrapper' => 'mymodule_result_div',
)
);
with a hierarchical_select instead simply select.
Regards
Comment | File | Size | Author |
---|---|---|---|
#2 | hs_test.zip | 1.67 KB | johaziel |
Comments
Comment #1
Wim LeersConfirmed. I don't have the time to fix this right now, though.
Comment #2
johaziel CreditAttribution: johaziel commentedHi again ...
I found this code in http://drupal.org/node/326300#comment-1216927
but nothing happends too !
what's wrong ? I'm testing with the example describe in the API.txt and a script javascript
I use :
drupal 7.7
firefox 6.0.2
ubuntu 11.04
all hierachical_select's modules are enable
somebody can test if it's work for you.
Thanks
Comment #3
Wim LeersIt's probably broken in D7. In D6, it should work just fine. Try it on a D6 test site to make sure this is a regression. That'd be helpful in moving this issue forward and would allow me to solve it quicker (since I wouldn't have to test that anymore).
Comment #4
johaziel CreditAttribution: johaziel commentedYes that's work fine on D6.
I tried to look in hierarchical_select.js if something was wrong but my level is not so high to see where the error is. If you have a track maybe I can do somethings.
I'm willing to participate in an attempt to fix this bug because it's important to me.
Comment #5
alexverb CreditAttribution: alexverb commentedHas this issue been looked at since? I'm also trying to find out why the events are not being fired. But not having any luck at the moment. Like johaziel said, maybe someone can point us in the right direction to find the culprit and fix this bug. Any help is appreciated.
Not having AJAX capabilities through an HS form element doesn't seem like a minor issue. Changing it to major.
Comment #6
alexverb CreditAttribution: alexverb commentedI've been comparing the javascript workflow of Hierarchical Select between D6 and D7. I've found that in D6 the event is triggered twice in the following code at line 446:
It's triggered one time for "before-add-to-dropbox" and one time only for "add-to-dropbox". In D6 I'm also able to bind stuff to the event. So I assume this is the way it's supposed to work.
In D7 I pass the breakpoint 3 times:
I think the problem is nearby. I'm still plowing through the javascript hoping someone may step in and help me out ;).
Comment #7
ckristo CreditAttribution: ckristo commentedHi,
First of all: Thanks Wim Leers for your great module :-)
I don't think that the event isn't triggered, but I think the function the user bound to the event is not bound anymore. I bound a custom function using the following code when the DOM is ready:
My function is called if I add the first element from the HS to the dropbox. Here's my debug output:
When I try to add another element from the HS to the dropbox, I get:
So my function isn't executed anymore. I had a similar problem once developing my own module: I attached a change event to a select on page load using jQuery. Later on I replaced the complete HTML code of the select with an AJAX callback -- and the event didn't fire anymore. I had to re-attach the event after replacing the HTML.
The 'add-to-dropbox' event is called after the AJAX callback, and therefore the user bind is gone before the function is fired once...
I don't know the Drupal 7 AJAX API - but maybe Drupal 7 overwrites the complete HTML while Drupal 6 did only change certain innerHTML values.
-------------
Kind Regards
Christoph
Comment #8
mibfire CreditAttribution: mibfire commentedI did some research in this and what i have managed to figure out that drupal is not responsible for this.
In d7:
After ajax is called the whole box will be replaced.
In d6:
Only the html inside the box will be replaced.
So if it is replaced in d7 then the old events should be saved and attach to the new one.
There is a workaround for this if you wanna call your function after ajax replaces the content.
In jquery 1.7 there is an event called remove that is triggered if an html elem is removed. So you can attach a function to this.
For example:
Comment #9
mibfire CreditAttribution: mibfire commentedI found a solution for this.
You can use live function of jquery.
The document should be rewritten accordingly.
Comment #10
stefan.r CreditAttribution: stefan.r commentedIt seems this is a documentation issue, not a bug?
Comment #11
stefan.r CreditAttribution: stefan.r commentedCommitted a note to API.txt