Hi,

I'm experiencing some problems with shadowbox and views.

I set up a table listing with imagefield as shadowbox, node title, etc.... and some exposed filters.

I enabled ajax in my view setup to have ajax pagination, table ordering and ajax exposed filters.

Shadowbox works correctly when I go to the page, but if I do a view ajax call (change pagination, exposed filter search or table ordering). Then, if I click on my image, shadowbox stop working and my image is opened normally, as a link.

I think shadowbox need to have a jquery trigger that take care of views. Maybe an ajaxComplete call or something like that.

CommentFileSizeAuthor
#13 shadowbox_auto.patch229 bytesericdfields

Comments

paulvantuyl’s picture

This problem also happens if you click on a shadowbox link before a page is finished loading. It would be really good if somehow the link didn't work until the page was finished loading so that it always opens in shadowbox. Also, if you click on a shadowbox link for a .flv before the page is finished loading, Firefox asks you if you want to open or save the file. No good for me...

psynaptic’s picture

Hey zmove, sorry to not get back to you on this sooner..

I'm not sure how to fix this. If you have any code I could use that would be awesome.

I've committed a fix for the problem mrMaze is talking about. He found that using document.ready worked better than window.load. This might have an effect on the issue you mentioned but I doubt it. Any more info would be much appreciated.

zmove’s picture

Hi,

Yes, I noticed that document.ready was better than window.load. I find a beginining of fix using the jquery ajaxComplete trigger, but I never completely fixed it.

I'm on another project now, so I stopped working on this.

psynaptic’s picture

Ahh, if you end up going back to it I would love to know how you tackled it. Thanks anyway.

psynaptic’s picture

Status: Active » Postponed
psynaptic’s picture

I fixed the issue with the content not being opened in Shadowbox if the Dom was not ready. I'd still love to find a fix for the ajax views issue.

druryjeff’s picture

Not sure if this is helpful or not, but it should point you in the right direction. I'm using the jQuery Pagination plug-in (straight, with no Drupal module) to display a series of panels containing links to videos that display using Shadowbox. As with the other folks on this post, after the first page link is clicked the Shadowbox links stop working (the videos are loaded on separate pages instead of in a Shadowbox/modal window).

To remedy this, you need to re-run the Shadowbox setup when page links are clicked. I did this by adding a call to the Shadowbox.setup(); function inside the pageSelected(); function inside my jquery.pagination.js file.

The modified function looks something like this:


function pageSelected(page_id, evt){
  current_page = page_id;
  drawLinks();
  var continuePropagation = opts.callback(page_id, panel);
  if (!continuePropagation) {
    if (evt.stopPropagation) {
      evt.stopPropagation();
      Shadowbox.setup(); // the function call to run the Shadowbox set-up
    } else {
      evt.cancelBubble = true;
    }
  }
return continuePropagation;
}

psynaptic’s picture

Would love a patch for this!

jwaxman’s picture

I had the same problem.
I just put

<script type="text/javascript">
  Shadowbox.setup();
</script>

in the footer of the view with PHP input format and all is well.
Not elegant but ...

phayes’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Postponed » Needs review

This is super-duper easy to fix. shadowbox_auto.js should be as follows:

Drupal.behaviors.shadowbox = function (context) {
  var settings = Drupal.settings.shadowbox;
  if (settings.auto_enable_all_images == 1) {
    $("a[href$='jpg'], a[href$='png'], a[href$='gif'], a[href$='jpeg'], a[href$='bmp'], a[href$='JPG'], a[href$='PNG'], a[href$='GIF'], a[href$='JPEG'], a[href$='BMP']").each(function() {
      if (settings.auto_gallery == 1) {
        $(this).attr('rel', 'shadowbox[gallery]');
      }
      else {
        $(this).attr('rel', 'shadowbox');
      };
    });
  };
  Shadowbox.setup();
};

The only change is that I added shadowbox.setup(); at the bottom of the behavior. This behavior is called on every ajax or AHAH reload - so this means that shadowbox will be re-triggered on every new piece of content. I could do this up as a patch if the maintainers want, but it's such a simple fix.

nicholas.alipaz’s picture

Status: Needs review » Postponed (maintainer needs more info)

can you create a patch for this against the latest version of shadowbox dev? http://drupal.org/patch/create

ericdfields’s picture

Does this really need a patch? I just called Shadowbox.setup() as part of my callback.

		$('#block-views-explore-block_1').load($(this).attr('href') + ' #content-area',function(){
			Shadowbox.setup();
		});

And it works.

Now I just need similar for activating AJAX pagination in the view I'm loading up there too…

ericdfields’s picture

StatusFileSize
new229 bytes

OK so a little tweaking to how we're setting up our site and it turns out the fix was needed after all!

Created a patch. Attached.

nicholas.alipaz’s picture

Version: 6.x-3.x-dev » 6.x-4.x-dev
Category: support » bug
Status: Postponed (maintainer needs more info) » Fixed

This has been committed to the latest dev version of 4.x branch. 4.x is really the suggested branch currently so I will leave it to just that. If we need it commited to 3.x or 2.x then please reopen this issue although it would be is a pretty minor issue to create a new release in those branches for this.

http://drupal.org/cvs?commit=349750

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Frederic wbase’s picture

Is the same already done for the 7.x version?
Everything you put in a theme behavior will autoreload if you perform an ajax call ;-)