Adding ajax feature for delete and js trigger to extend functionality.
Triggered and event which can be used to auto refresh the view which is attached.
Example code to auto refresh: 'views_save_update' is the custom event which is triggered.

  var viewsSave = {
    refresh: function () {
      var dom_id;
      $.each(Drupal.views.instances, function getInstance(index, element) {
        if (element.settings.view_name == 'view_name') {
          dom_id = '.view-dom-id-' + element.settings.view_dom_id;
          if (typeof dom_id !== 'undefined') {
            $(dom_id).trigger('RefreshView');
          }
        }
      });
    }
  };

  $('body').on('views_save_update', function() {
    viewsSave.refresh();
  });
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pradeep22saini created an issue. See original summary.

pradeep22saini’s picture

Issue summary: View changes
FileSize
3.63 KB
pradeep22saini’s picture

Status: Active » Needs review
drunken monkey’s picture

Thanks for posting this!
Aside from a few code style issues, this does seem sensible. However, I'm not sure whether it's actually useful enough to be committed to the module, it seems rather specific and kind of a niche functionality (which you could also implement in your own custom module, as far as I can see).
I'll think about it, but will probably wait until there are other people interested in this.

Also, why do you trigger the event on the body and not the window – any specific reason? And why has the event a different name than the command, isn't that confusing?

pradeep22saini’s picture

thanks for Review @drunken monkey

I have made some changes and updated the patches with few modification with ajax refresh.

drunken monkey’s picture

+++ b/views_save.module
@@ -77,7 +81,6 @@ function views_save_url_inbound_alter(&$path) {
-        $_GET['views_save'] = $id;

Why this change? That seems to be completely unrelated, and also like it would break existing functionality.