Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers

up vote 0 down vote accepted

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));
share|improve this answer

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.

share|improve this answer
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 ? – infensus Oct 19 '12 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. – f.gorczynski Oct 22 '12 at 11:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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