Problem with jQuery Colorbox

吃可爱长大的小学妹 提交于 2019-12-11 13:37:10

问题


I have a website that uses ajax jquery and colorbox.

Inside the div "#content" there are some links to other pages that open fine using colorbox.

If I reload the content of that div using ajax jquery , then the links wont popup using colorbox effect anymore.

I tried to create a function that I would call whenever I call the function that changes the contents of div #content , but no luck . I know that I must reinit/reload the colorbox to DOM everytime I load something new to the page that contains rel="colorbox" ,but I cant figure it out how.I call this inside

function showcategory() {
reinit();
...
}

function reinit() {
  $('a[rel*=colorbox]').colorbox() ;
}

回答1:


try to attach your handler using live instead of bind. This survives content-reloads in the divs

the api doc for live is here




回答2:


You will have to use the live() method or delegate method for dynamic generated content events.



来源:https://stackoverflow.com/questions/3409796/problem-with-jquery-colorbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!