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.
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();
});
Comment | File | Size | Author |
---|---|---|---|
#5 | views_save_refresh_update.patch | 4.34 KB | pradeep22saini |
#2 | views_save_refersh_delete_update.patch | 3.63 KB | pradeep22saini |
Comments
Comment #2
pradeep22saini CreditAttribution: pradeep22saini commentedComment #3
pradeep22saini CreditAttribution: pradeep22saini commentedComment #4
drunken monkeyThanks 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?
Comment #5
pradeep22saini CreditAttribution: pradeep22saini commentedthanks for Review @drunken monkey
I have made some changes and updated the patches with few modification with ajax refresh.
Comment #6
drunken monkeyWhy this change? That seems to be completely unrelated, and also like it would break existing functionality.