Skip to content
Snippets Groups Projects

Issue #3352648: Unloading a view

1 file
+ 20
6
Compare changes
  • Side-by-side
  • Inline
+ 20
6
@@ -53,20 +53,34 @@
submit: view_info,
url: drupalSettings.path.baseUrl + 'views/ajax',
element: item,
event: execute || 'click',
progress: { type: 'fullscreen' },
httpMethod: method,
};
var ajax_call = Drupal.ajax(ajax_settings);
// Load right away.
if (execute) {
ajax_call.execute();
// Load right away.
this.loadLazyAjax(ajax_settings);
}
else {
// Load and unload on click.
$el.on(execute || 'click', function (e) {
e.preventDefault();
if ($el.hasClass('loaded')) {
$el.removeClass('loaded');
$('.js-view-dom-id-' + view_dom_id).empty();
}
else {
$el.addClass('loaded');
Drupal.behaviors.lazyViewsAjax.loadLazyAjax(ajax_settings);
}
})
}
}
},
loadLazyAjax: function (ajax_settings) {
let ajax_call = Drupal.ajax(ajax_settings);
ajax_call.execute();
}
};
})(jQuery, Drupal);
Loading