1

I'm trying to have a simple block of flags for my site. I created a block view of content of my custom product type with a relationship to Flags: my_product (by any user).

The issue is have is that the block is only refreshed if I used the confirmation form link type. Is there a way to get the list to refresh (and the block to be updated) with using the other link types?

thanks in advance.

0

Since this tumbleweeded the answer is that there are a few modules that to time based refreshes of the view. Views by default, serves up content that ends up being static. Refreshing a view can be done a number of different AJAXY ways with custom code, but one of the more interesting involves using the Drupal node.js module and refreshing the view based on the execution of the flagging event. But using node.js you can have the view refreshed by server-side events (i.e. submissions by other users) all behind the scenes!.

Views Auto-Refresh is interesting but only has the on-click functionality in it's feature request que. I haven't developed a working implementation of this, but the node.js route is the one I would pursue at the moment.

A little more research turned up this little bit of jquery posted with a good explanation here Jquery views refresh

/**
 * @file
 * This JavaScript reacts to certain AJAX events on the view.
 */

jQuery(document).ready(function(){
  jQuery('input[type="submit"][name="op"][value="Save"]#edit-submit').hide();
})

/**
 * Function built on wireframe from
 * https://drupal.org/node/1781988#comment-6835168
 */
Drupal.behaviors.my_view_machine_name = {
  attach: function(context, settings) {
    if (Drupal.views !== undefined) {
      jQuery.each(Drupal.views.instances, function(i, view) {
        if (view.settings.view_name == "my_view_machine_name") {
          jQuery(document).ajaxComplete(function(event, xhr, settings){
            jQuery('input[type="submit"][name="op"][value="Save"]#edit-submit').hide();
            var response = JSON.parse(xhr.response);
            var resp_keys = Object.keys(response[0].settings.ajax);
            if (response[0].settings.ajax[resp_keys[0]].callback == "editablefields_form_update") {
              jQuery('#view-auto-refresh').click();
            }
          });
          view.$view.once('view-refresher', function() {
            var html = '<a class="view-refresher" href="' + view.settings.view_path + '" id="view-auto-refresh" style="display:none">Refresh</a>';
            view.$view.append(jQuery(html).each(jQuery.proxy(view.attachPagerLinkAjax, view)));
          });
          return false;
        }
      });

    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.