1

I created and customized exposed forms. When I change some values I change exposed filters widgets accordingly. Then I call submit with JavaScript, but my form is send with regular submit not like I checked on Views Advanced Settings form to use AJAX. What could be wrong with that? Pagination also change current URL.

-- edit -- When I click on item connected with exposed filter I execute this code:

$('#category-product-finder .frame a').each(function() {
    var $a = $(this);
    var $exposed_filter = $('#views-exposed-form-product-finder-page');
    $a.click(function(e) {
        e.preventDefault();
        $exposed_filter.find('#edit-product-category').val($a.attr('rel'));
        $('#views-exposed-form-product-finder-page').trigger('submit');
    });
});

And this make my form to submit without using AJAX.

2 Answers 2

0

Did you edit the templating of view? As AJAX views use the default ID's to attach itself to the form and view itself. If you've altered / removed these ID's, it would explain why the form submits in a regular way.

A few lines of the selectors in ajax_views.js to get you on the right path:

var selector = '.view-dom-id-' + settings.view_dom_id;

...

// Add the ajax to exposed forms.
this.$exposed_form = $('form#views-exposed-form-'+ settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'));
this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));
1
  • This helped me. I had removed the attribute classes from my wrapper div. Thanks a ton! Saved me a lot of banging my head against the table. +1 Mar 9, 2018 at 16:19
1

Found a solution. Ambidex idea is the key. My problem was that I didn't have printer classess within views-view--XXXX.tpl.php. After this everything works OK and there is something like "view-dom-id-82374yrcnuerhnw875yt3o8743y" (first line of Ambidex code) class added, which is probably needed by AJAX calls.

2
  • What do you mean by printer classes (have same problem). I already have the view-dom-id-xxxxx class on my view which needs to be filtered. Still doesn't even work without any custom TPLs ?
    – Dominic
    Oct 19, 2012 at 11:26
  • There should be printeD classes. <div class="<?php print $classes; ?>"> <?php echo $exposed; ?> <?php if ($rows): ?> <ul class="products"> <?php echo $rows; ?> </ul> <?php endif; ?> </div> First I missed print $classess which is required by Drupal; I created views with exposed filters - then hide it with CSS and display another view (nice looking) to manage exposed filters. Oct 22, 2012 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.