I'm trying to make an imagemap's .click() event trigger two things:

a) the selection of an item in an Exposed Filter of a view
b) the subsequent submission of the AJAX to refresh the view based on the new filter

I have a view set up with AJAX enabled. My jQuery looks like this:

jQuery('#northside').click(
function () {
jQuery('#edit-tid').val("1");
jQuery('views-exposed-form-frontpageplaces-block').ajaxSubmit();
}
);

I'm sure that .ajaxSubmit() isn't the correct syntax here, but I was trying to use Malsup's JQuery Form plugin.

It seems that this guy has a similar problem.

Am I doing something completely off-base here? How do I fix it?

Comments

warrenmcquinn’s picture

Title: AJAX Autosubmission not triggering on JQuery value change » AJAX Autosubmission not being triggered on JQuery value change
warrenmcquinn’s picture

Project: Views (for Drupal 7) » Chaos Tool Suite (ctools)
Version: 7.x-3.1 » 7.x-1.x-dev
Component: exposed filters » Modal
j0rd2’s picture

Issue summary: View changes

I'm changing a input value to do some spam protection with javascript before submissions.

It works fine in non-ctools-modal form, but then doesn't have in ctools-ajax-modal-form submission.

Additionally in chrome inspector, I can see the value change, but in hook_validate hook_submit, the value is not changed. I have a feeling there's some order of operations problem.

So...

bump.

j0rd2’s picture

      // Bind our custom event to the form submit
      $('#modal-content form', context).once('ctools-use-modal', function() {
        var $this = $(this); 
        var element_settings = {};
                                                                                                                                                                                       
        element_settings.url = $this.attr('action');
        element_settings.event = 'submit';
        element_settings.progress = { 'type': 'throbber' }
        var base = $this.attr('id'); 

        Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
        Drupal.ajax[base].form = $this; 
                                                                                                                                                                                       
        $('input[type=submit], button', this).click(function(event) {
          Drupal.ajax[base].element = this; 
          this.form.clk = this;
          // An empty event means we were triggered via .click() and
          // in jquery 1.4 this won't trigger a submit.
          if (event.bubbles == undefined) {
            $(this.form).trigger('submit');
            return false;
          }
        });
      }); 

Perhaps this?

Drupal.ajax[base].form = $this;

and then later trigger('submit') happens (which is where I modify my form values. But since the Drupal.ajax[base].form is already set, it won't get changed and that's what gets submitted?

mustanggb’s picture

Status: Active » Closed (outdated)