Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am rendering a view in the form, i have a list of product in the drop down, if any one is selected the view should refresh and show the selected product.
I am do this by using jQuery and call a function on change on the drop down list
Drupal.behaviors.blockRefresh = {
attach: function (context, settings) {
Drupal.views = {};
Drupal.views.instances = {};
Drupal.views.ajaxView = function (viewSettings) {
if (viewSettings.view_name == "recommended_product_view") {
var selector = '.js-view-dom-id-' + viewSettings.view_dom_id;
jQuery(selector).trigger('RefreshView');
}
jQuery(selector).unbind();
}
}
}
this works well only for the first time when the product is selected the function is called and refreshes the view and load the product.
But when i again select another product the function is called "jQuery(selector).trigger('RefreshView');" but it does not refresh the view.
Comments
Comment #2
cilefen CreditAttribution: cilefen commentedComment #3
vinaySreedhara CreditAttribution: vinaySreedhara commentedGot this working by this code.