This isn't really a question specific to colorbox, but it involves colorbox in my scenario, and I'm wondering how to manually kick off the colorbox init process? In my case, it is processing the dom elements in the initial page render, but I am adding some elements via an ajax callback and I want it rescan the dom after that to process items I have just added. It looks like colorbox is set up to do this, but I think it is an issue with the context in which the ajax callback executes and that means that colobox doesn't run it's 'attach' routine when I add my elements. I _think_, anyway.

The details for my specific situation:

I have colorbox installed and running fine. I have a heavily customized version of the chatroom module, where I have added file uploads and a bunch of other stuff.

This uses nodejs to pass messages around to clients. My chatroom allows users to upload images and they get inserted into my chat area. This happens with an ajax-submitted form. Submitting the images works, they are passed through nodejs and through the entity_view function and the proper input filters and get the colorbox class added to them fine. They show up, having passed through the drupal rendering pipeline in all the clients browsers immediately and are in the DOM. But colorbox doesn't run them.

This works for all images already posted, but the image posting happens via ajax, and when a new image is posted it shows up but has not been ajax processed, so I think all I need is a way to tell the client to re-run the colorbox attach routine when a new image is posted. Or, I guess I could run .colorbox() manually on them, but that seems redundant since the facility for doing that already exists in the colorbox attach function.

Any ideas would be helpful.

Thanks,
Cliff

Comments

meecect created an issue. See original summary.

frjo’s picture

Status: Active » Fixed

I think what you are looking for is "Drupal.attachBehaviors();". Read more at https://www.lullabot.com/articles/understanding-javascript-behaviors-in-...

Status: Fixed » Closed (fixed)

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