If a select had an Ajax function, this don't work.

Any idea?
Thanks

CommentFileSizeAuthor
#4 dropkick-ajax-1342002-4.patch983 bytesstevetweeddale

Comments

mistergroove’s picture

Some how we need to bind the onchange events on the select to dropkicks change event...

$('.change').dropkick({
change: function (value, label) {
// fire select onchange event
}
});

This would be amazing if this could be done in the dropkick jquery library - so it automatically takes the selects events and binds them onto the dk dropdown....

I wish I was better at jquery event handling...

vivekguptakota’s picture

Priority: Normal » Critical

I am facing same problem.So please let me know any ideas.
It is very urgent form me.

calebtr’s picture

I got around this by skipping this module, leaving the library installed and adding everything manually.

In a custom module, I added:

  drupal_add_js('sites/all/libraries/dropkick/jquery.dropkick-1.0.0.js', 'file');
  drupal_add_css('sites/all/libraries/dropkick/dropkick.css', 'file');

Then to trigger some event for a select with id='myselect':

drupal_add_js("jQuery(document).ready(function(){jQuery('#myselect').dropkick({ change: function(value, label) { window.location = value; } }); });", 'inline');
stevetweeddale’s picture

StatusFileSize
new983 bytes

Here's a patch!

It just sets the 'custom change callback' to fire the change event on the original select element. To be honest, I don't know why dropkick doesn't just do this by default. With jQuery around, binding to a select element's change event is just as easy as providing the plugin with 'custom change callback'.

mossill’s picture

still having issues on the second time i click a drop down menu...

The first time works correctly, the .change() executes but for some reason the ajax form is not submitted the second time.

mossill’s picture

Here is a quick and dirty fix to the patch you posted. I altered the Dropkick.js file in the modules folder. I had to pull the class name from the object to get it to work correctly on the select element after the behavior change.

////////////////////////////////////////////////////////////////////

(function($) {
Drupal.behaviors.dropkick = {
attach: function(context) {
$(Drupal.settings.dropkick.selector, context)
.not('#field-ui-field-overview-form select, #field-ui-display-overview-form select') //disable dropkick on field ui
.each(function() {
$(this).dropkick({
change: function (value, label) {
obj = this;
element = obj.context.className;
$('.' + element).val(value).change();
}
});
});

//add clearfix to parent .form-item to fix floats
$('.dk_container').parents('.form-item').addClass('clearfix');
}
}
})(jQuery);

//////////////////////////////////////////////////////////////////// dropkick.js

huijing’s picture

Issue summary: View changes

This issue is still present in 7.x-2.x

  • saniyat committed 0e38adf on 7.x-1.x
    Fixed #1342002: Dropkick break Ajax
    

  • saniyat committed f7ec632 on 7.x-2.x
    Fixed #1342002: Dropkick break Ajax
    
saniyat’s picture

Status: Active » Fixed

Issue fixed and committed to dev branch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.