I am loading a set of images from another page using jquery load()
function. I want the images that are loaded to be able to trigger the colorbox script but it is not working. I have all of the scripts on the page that triggers the load, but the script does not get applied to the fresh ajax content. How could I make this work?
Thanks for the responses! It now works using the on function.. so I have something like this :
<a href="http://something.com" class="cbox"><img ... /></a>
$j(".cbox").on( "click", function(){
$j.fn.colorbox({ iframe:true, scrolling: false, innerWidth: '650px', innerHeight: '390px' });
return false;
});
It seems to sort of work.. however now colorbox cant grab the href, it is returning that as undefined... but I guess that is another matter.
Use jQuery's new .on()
method, which replaces .live()
and .delegate()
. It works on elements that were added to the DOM after the code ran.
Had you posted some code, I'd have some to post back, but basically it looks like
$('imgselect').on('event',function(){
//do stuff
});
event
can be mouseenter
, mouseleave
, click
, etc.
http://api.jquery.com/on/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With