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 have a rule link in a view that, along with other things, deletes the node. Is there a way to trigger a view refresh after the rule link has been clicked - similar to the views flag refresh module?
Comments
Comment #1
jelhan CreditAttribution: jelhan commentedI did not tested it, but what's about you just using an page redirect action on the rule which points to the same page? Shouldn't this work as a refresh?
Comment #2
bennos CreditAttribution: bennos commentedyeah this works, but it reload the complete page new.
what bjalford means is a ajax refresh of only the view itself.
sounds interesting
Comment #3
fishfree CreditAttribution: fishfree commentedsubscribe
Comment #4
loparr CreditAttribution: loparr commentedYes there is a way.
Just use this code inside your custom js file. Replace your_view_id with a desired view.
Comment #5
Yuri CreditAttribution: Yuri commentedHere is another vote for the ajax refresh feature.
It might be interesting to look how the flag module has solved the same issue with this module:
https://www.drupal.org/project/views_flag_refresh
Comment #6
kopeboy CreditAttribution: kopeboy as a volunteer commentedYep, don't we have everything we need?
I am not a developer and I've never done a module or a patch, but I would like to help :(
This would be very useful.
Comment #7
maxplus CreditAttribution: maxplus commentedthanks @loparr, your code works for me.
For people who don't know where to find your_view_id, read this: https://www.drupal.org/node/1259304
=> I set my view to a display_id of my own choice instead of the default chosen by Views
I also had another problem that Rules links keeps redirecting to my front page but after I used the current DEV version and set it to "javascript", that problem was also solved (see https://www.drupal.org/node/2630304 and https://www.drupal.org/node/2549881#comment-11900104)
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedIf somebody else is fighting with the code from #4 only refreshing the view after the second click here is how I got it working:
Modification is only to add the (document).ready function above the click function.