diff --git a/js/ajax_view.js b/js/ajax_view.js index 2a4012f..817d562 100644 --- a/js/ajax_view.js +++ b/js/ajax_view.js @@ -13,6 +13,19 @@ Drupal.behaviors.ViewsAjaxView.attach = function() { $.each(Drupal.settings.views.ajaxViews, function(i, settings) { Drupal.views.instances[i] = new Drupal.views.ajaxView(settings); }); + + //Trigger the previous filtered search. + if (window.location.hash) { + $exposed_form_submitted = $(window.location.hash); + //We have a hash that corresponds to the + if ($exposed_form_submitted.hasClass('ctools-auto-submit-full-form')) { + $exposed_form_submitted.once(function() { + var button = $('input[type=submit], input[type=image]', $exposed_form_submitted); + button = button[0]; + $(button).click(); + }); + } + } } }; @@ -59,6 +72,7 @@ Drupal.views.ajaxView = function(settings) { // 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)); + this.$exposed_form.ajaxComplete(jQuery.proxy(this.ajaxCompleteCallback, this)); // Add the ajax to pagers. this.$view @@ -68,6 +82,12 @@ Drupal.views.ajaxView = function(settings) { .once(jQuery.proxy(this.attachPagerAjax, this)); }; +Drupal.views.ajaxView.prototype.ajaxCompleteCallback = function(event, request, options) { + if (options.url === this.element_settings.url) { + window.location.hash = this.$exposed_form.attr('id'); + } +} + Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() { var button = $('input[type=submit], input[type=image]', this.$exposed_form); button = button[0];