jQuery ColorBox real multiple instances

2019-08-20 19:03发布

This question was asked before in a Google Group, but never really answered, and the group closed by the ColorBox developer Jack Moore (amazing plugin btw, thanks!).

I want to create REAL multiple instances of a ColorBox lightbox. This in order to be able to open a lightbox instance and then when closing it, only hiding instead of removing it from the dom. I developed a Moodle Activity Module that supports a lightbox option. And in my course page I have multiple instances of the ColorBox lightbox (each containing an iframe). When a student is browsing through a book, or whatever content, in the opened lightbox and he closes it, he later must be able to open it again with the book content in the same position/state as it was when he closed it.

I guess this is not a standard feature, but has someone found a way to do this? To keep the colorbox instance/div and, if it already exists, later just un-hiding it again?

2条回答
我只想做你的唯一
2楼-- · 2019-08-20 19:44

You can call on close event new color box. Example:

$.colorbox({
  html:'test',
  onClosed::function(){
        // open the other colorBox   
        $.colorbox({html:'test'});
    }
});
查看更多
forever°为你锁心
3楼-- · 2019-08-20 19:46

Sorry, I don't think there is going to be a practical way to do this. You would have to re-code a lot of the plugin for it to support multiple instances.

You may be able to keep your iframes as different pieces of inline content. I'm not sure if moving an iframe around the DOM will cause it to lose it's scrolltop position or not.

查看更多
登录 后发表回答