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

vinaySreedhara created an issue. See original summary.

cilefen’s picture

Assigned: vinaySreedhara » Unassigned
Category: Task » Support request
Issue tags: -Views Ajax Problems
vinaySreedhara’s picture

Status: Active » Fixed

Got this working by this code.

Drupal.behaviors.blockRefresh = {
    attach: function (context, settings) {
      jQuery.each(Drupal.views.instances, function (i, view) {
        var selector = '.js-view-dom-id-' + view.settings.view_dom_id;
        if (view.settings.view_name == "recommended_product_view") {
          $(".product--default").removeClass("highlight");
          jQuery(selector).triggerHandler('RefreshView');
        }
        jQuery(selector).unbind();
      });
    }
  }

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.