I have a page where I have several carousel views that can, at times, show the same item/node in each carousel. Such as a most downloaded and a most viewed. I have two different flags (bookmarks and cart) I need to update across the page as well as views blocks that lists out all of the flagged items for each of these.

So as I have been working on just how to do this I have run into some stumbling blocks. First of all I can hook into the flags JS API to initiate this, which is fantastic. I can even identify all of the flags of the type that has been acted upon which apply to the updated flag.

However I have ran into the following problems:

  1. When looping through all of the identical items with say the bookmarks flag I don't seem to have a way to differentiate it from the other flags on the page that need to be updated. My concern is that by looping through all of them I will inevitably leave the flag I clicked on in the same state and all of the other duplicate flags on the page in the new state.

    $(document).bind('flagGlobalAfterLinkUpdate', function(event, data) { //Your code here });

  2. I want to prevent the flags JS from showing the popup messages on each click such as "item added to bookmarks" and instead pass that to jGrowl. I know how to generate it in jGrowl, I just need to figure out how to capture that message and show it my way.

  3. Finally I need to update the related views block on the page when this is done. Say the bookmarks list block.

So what I would like to know is first, how do I deal with updating the same item's flag on multiple places on the page when it has duplicates? Secondly I want to know how to capture that message and redirect it to my tool (jGrowl). Lastly is how do I update a view block on a page with AJAX?

I want to do all of the updates without reloading the entire page.

Currently I am running this on Drupal 7 with Views 3 and using Nice Messages to generate system messages in a Growl-like format.

Thanks, Patrick


I just ran into the same problem. This is how I handled updating duplicate flags on a page:

    $(document).bind('flagGlobalAfterLinkUpdate', function(event, data) { 

        if(data.flagStatus == "unflagged"){
            $('.flag-favourite-' + data.contentId + ' a').each(function(){

            $('.flag-favourite-' + data.contentId).each(function(){                  


change out the term favourite with the machine name of you flag and it should work...

| improve this answer | |
  • Lol, I actually resolved my issue back in September, but I completely forgot to post it. I am going to go ahead and give you the credit here since I don't remember my answer and yours looks good. – Patrick Dec 5 '11 at 18:49

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.