text Ajax新项加载问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Ajax新项加载问题相关的知识,希望对你有一定的参考价值。


https://aiocollective.com/blog/click-doesn-t-work-after-ajax-load-jquery/

// 

function menuVideo() {
    var videoSrc = '' ;
    jQuery(document).on('click', '.video-btn' ,function() {  // this works because it adds new elements "load" and now our event listeners are aware of these new elements
    // this wont work because click works on current "existing" elements, 
    // any new elements added via ajax are invisible and will just return null
    // jQuery('.video-btn').click(function() {  
    
        videoSrc = jQuery(this).data( "src" );
    });
    console.log('Video Src: ' + videoSrc );

    // when the modal is opened dont autoplay it
    jQuery('#myModal').on('shown.bs.modal', function (e) {
        // Update video src with the one that was currently clicked, using fadeIn for a smooth transition
        jQuery("#video").attr('src',videoSrc + "?rel=0&showinfo=0&modestbranding=1&autoplay=0" ).fadeIn();
    }) ;

    // stop playing the youtube video when I close the modal
    jQuery('#myModal').on('hide.bs.modal', function (e) {
        // When this video is closed, clear video attribute src so that it does not display the previously played video
        // before showing the next one
        jQuery("#video").attr('src', '') ;
    }) ;
}




以上是关于text Ajax新项加载问题的主要内容,如果未能解决你的问题,请参考以下文章

text 加载ajax popup django html javascript

新内容不继承父 div 的无限滚动样式

jQuery+php+Ajax文章列表点击加载更多功能

Echarts通过Ajax实现动态数据加载

Ajax方式分页加载列表实现

ExtJs之Ajax模式的表单数据加载