weixin_33738578 2011-09-08 23:41 采纳率: 0%
浏览 35

colorbox无法与Ajax一起使用

I am trying to open colorbox from dynamically loaded contents from ajax calls. On click of next it loads another block on the page and on clicking on that block, colorbox overlay should be opened.

But for the first item colorbox is opened, then after i am not able to bind colorbox with the link.

Please see, my javascript code which is used to bind colorbox is:

$(document).ready(function() {
    $('#recommended-app-wrapper .app_download_link').each(function() {
        $(this).colorbox({
            href: $(this).attr('href'),
            iframe: false,
            onComplete: function() {
                //  Tooltip
                $('#modal a.link_tooltip').each(function() {
                    $(this).click(function() {
                        return false;
                    });
                    var content = $(this).next('.hidden').html();
                    $(this).aToolTip({   
                        tipContent: content,
                        fixed: true,
                        clickIt: false,
                        xOffset: -180,
                        yOffset: 30
                    });
                });
                //  Clear-Default
                $('#modal input.clear-default').clearDefault();
            }
        });
    });
});    

JSP code which calls the content page is

<dsp:a page="/fragments/product_app_download.jsp" iclass="custom custom-blue-smapp_download_link get-app">
    <dsp:param name="id" param="element.id"/>
    Get app
</dsp:a>

Please see the main page, from where the ajax call is being made and it loads the block from which user can click and open the colorbox. I have taken the screenshot of the code.

http://i.imgur.com/Z0BVQ.png

I think, the issue is , i am binding the colorbox on document.ready which is called only one time, then after on clicking of next it doesnt bind my next item to colorbox.

Kindly help.

thank you

  • 写回答

2条回答 默认 最新

  • ~Onlooker 2011-09-09 00:49
    关注

    You can use the jquery .live() function to bind events to elements that haven't even been created it. I think this is what you might need.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!