亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在動態元素上綁定引導彈出窗口

如何在動態元素上綁定引導彈出窗口

慕田峪7331174 2019-12-21 13:13:11
我正在動態列表上使用Twitter Bootstrap的彈出窗口。列表項有一個按鈕,當我單擊該按鈕時,它將顯示彈出窗口。當我在非動態環境下進行測試時,它可以正常工作。這是我的非動態列表JavaScript$("button[rel=popover]").popover({     placement : 'right',    container : 'body',    html : true,    //content:" <div style='color:red'>This is your div content</div>"    content: function() {      return $('#popover-content').html();    }    })    .click(function(e) {        e.preventDefault();});但是,它在動態列表上效果不佳。當我單擊“兩次”按鈕時,它可以顯示,并且僅顯示我單擊第一時間的列表項之一。我的HTML: <ul id="project-list" class="nav nav-list">   <li class='project-name'>     <a >project name 1         <button class="pop-function" rel="popover" ></button>     </a>   </li>   <li class='project-name'>     <a>project name 2        <button class="pop-function" rel="popover" ></button>     </a>   </li> </ul><div id="popover-content" style="display:none">    <button class="pop-sync"></button>    <button class="pop-delete"></button></div>我的動態JavaScript:$(document).on("click", "#project-list li" , function(){   var username = $.cookie("username");   var projectName = $(this).text()   $("li.active").removeClass("active");   $(this).addClass("active");   console.log("username: " +username + " project name: "+projectName );});$(document).on("click", "button[rel=popover]", function(){    $(this).popover({        placement : 'right',       container : 'body',       html : true,    content: function() {       return $('#popover-content').html();        }    }).click(function(e){    e.preventDefault();    })});//for close other popover when one popover button click$(document).on("click", "button[rel=popover]" , function(){        $("button[rel=popover]").not(this).popover('hide'); });我已經搜索過類似的問題,但是仍然找不到解決我的問題的方法。如果有人有什么想法,請告訴我。感謝您的幫助。
查看完整描述

3 回答

?
慕尼黑5688855

TA貢獻1848條經驗 獲得超2個贊

可能為時已晚,但這是另一種選擇:


 $('body').popover({

    selector: '[rel=popover]',

    trigger: 'hover',

    html: true,

    content: function () {

        return $(this).parents('.row').first().find('.metaContainer').html();

    }

});


查看完整回答
反對 回復 2019-12-21
  • 3 回答
  • 0 關注
  • 611 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號