I have a problem that I cannot understand:
I load content dynamically using jQuery on the TinyScrollbar. The content contains links that should run the ColorBox. For references to work, I used jquery delegate
. But after loading the content, my ColorBox only opens if I double-click the link .
(I suppose one of them will make jQuery understandable that there is a corresponding element, a second time to execute the delegate function.)
Here is my code:
$(document).ready(function() { var main = $('#main'); main.tinyscrollbar(); $(function(){ $(window).bind( 'hashchange', function(e){ var hash = location.hash; if (hash != '' && hash != ' ' && hash != 'undefined') { var urlToLoad = hash; $('.overview').load(urlToLoad, function(response, status, xhr) { urlToLoad = ""; main.tinyscrollbar_update(); }); } }); $(window).trigger( 'hashchange' ); }); $(document).delegate("a.video", "click", function(e){$(this).colorbox({iframe:true, innerWidth:700, innerHeight:394, fastIframe:false, transition:"none"});return false; }); $(document).delegate("a.img", "click", function(e){$(this).colorbox({transition:"none"});return false;}); });
source share