Hey there,

Cool module.

One thing... I have it working with an exposed filter for a view, and because you start your script with:


$(document).ready(function() {
  //this does the actual css/html replacement of the select dropdown
  $("select.jquery_dropdown").each(function(){
    $(this).load_jquery_dropdown();//load jquery dropdowns
  });
});

The ajax-loaded form comes back invisible!

To fix:


Drupal.behaviors.jquery_dropdown = function(context){
  //this does the actual css/html replacement of the select dropdown
  $("select.jquery_dropdown:not('.behaviors-processed')").each(function(){
    $(this).load_jquery_dropdown();//load jquery dropdowns
  }).addClass('behaviors-processed');
};

see here: http://drupal.org/node/304258

Comments

tmsimont’s picture

Same story in the jquery_dropdown_jump menu:

Drupal.behaviors.jquery_dropdown_jump = function(context){  
  $("ul.jquery_dropdown_jump:not('.behaviors-processed') li a").click(function(){
    if ($(this).attr('rel') == '') return;//don't jump if no value
    
    //find the parent form of this jump menu
    var parent_form = $(this).parents().filter("form");
   
    //submit the form by clicking the submit button 
    parent_form.submit();
  });
  $("ul.jquery_dropdown_jump").addClass("behaviors-processed");
};

ALSO -- notice that I changed the action to .submit() instead of .click() -- For some reason .click() doesn't behave as expected when trying to submit an ajax form (e.g. the views filter when "use ajax" is selected)

EDIT --
I tried putting the class onto the <a> but that messes with the fact that you put the reference to the select in the classsname!
So I put the behaviors processed on the <ul>

Thanks!

gregory claeyssens’s picture

Hi, this is nice, I'm having just those ajax problems.
I'm a newbie in this stuff, could you explain how I make sure these new functions get called?

I had made a theme.js (with the original module) with:

Drupal.behaviors.themeAttachJQDropDown = function(context) {
$('.view-filters select').each(function () {
$(this).addClass('jquery_dropdown jquery_dropdown_jump');
});
}

This made the function called on every page refresh but not when using the pager for my view (wich is ajax), but this does not work anymore. I got to be honnest, that code, I did not write it myself, and I barely understand it...

Anyway, Thank you in advance

EDIT: if you want to look at the problem i have: www.yu-card.be/yu/nl (this is before putting in your code, check the view at the bottom, after replacing with your functions the dropdownlists don't get made... :s)

gregory claeyssens’s picture

Never mind, i fixed it... It had to do with the classes, rookie mistake but hey, i learned something! thanks for the great code

Toxid’s picture

I tried to do this with an exposed view as well, but did not succeed. I added the class jquery_dropdown with a theme-javascript, perhaps it comes in too late then? How did you manage to add the class to the dropdown?

tmsimont’s picture

the key is swapping

$(document).ready(function() {

with

Drupal.behaviors.jquery_dropdown = function(context){

and adjusting the close of the script, too --
see here: http://drupal.org/node/304258