Note: I am using JS_Injector to load the JS code..

The issue: I have found that I have to duplicate some piece of JS code in order to load it upon initial page load and upon submitting the exposed form button via AJAX within same view.

Like this:

(function ($) {
$(document).ready(function() {

// CODE HERE //

});
})(jQuery);
(function ($) {
$(document).ajaxComplete(function(e, xhr, settings) {
if (settings.url == Drupal.settings.basePath + "?q=views/ajax" || settings.url == Drupal.settings.basePath + "views/ajax" || settings.url == Drupal.settings.basePath + "?q=system/ajax" ||  settings.url == Drupal.settings.basePath + "system/ajax") {  

// SAME CODE HERE //

  }       
}); 

})(jQuery);

Any better solution to avoid the replication ?!

Comments

W.M.’s picture

Issue summary: View changes
MustangGB’s picture

Status: Active » Closed (outdated)