colorbox not working when triggered from code (not by user action)
trying to do something really simple with colorbox, but for some reason it is not working:
I want to trigger color box from javascript code. When overlay loads I want it to display images - pretty simple st开发者_如何学Gouff.here is my code:
(in script block)
function c(){
$.colorbox({rel: "example1"});
}
(in HTML)
<p ><a href="files/1.jpg" rel="example1" title="test">pic 1</a></p>
<p ><a href="files/2.jpg" rel="example1" title="test 2">pic 2</a></p>
the problem is that when the colorbox is triggered it loads but does not load the images - the loading animation is displayed "forever"
figured it out with help from the community...
function c(){
$('a[rel=example1]').colorbox({open:true});
}
BTW, you would need the following in order to bind colorbox to the images:
$("a[rel='example1']").colorbox();
the function call triggers the already-bound colorbox (opens it).
精彩评论