【问题标题】:twitter bootstrap popover on ajax loaded contentajax加载内容上的twitter bootstrap popover
【发布时间】:2014-04-08 22:04:20
【问题描述】:

我正在尝试将 twitter bootstrap 中的弹出框分配给通过 ajax 加载的元素,我有这个:

        $(document).on("click", ".checkRezolvataTrecut", function(event){
        switch(dataCheckTrecut[1]) {
            case '02': 
                var luna = "Februarie";
                break;
        }
        $(".checkRezolvataTrecut").popover({
            placement: "top",
            content: "<button class='btn btn-default mutaTrecut' style='width: 100px;'>" + luna + "</button><button class='btn btn-default mutaCurent' style='width: 100px;'>Luna curenta</button>",
            html: true

        });
    });

问题是在第一次点击时没有任何反应。第一次点击后,它工作。顺便提一下,我不太了解 bootstrap js。有什么想法吗?

【问题讨论】:

  • 如果可能的话,把小提琴摆好。
  • 我不能,因为数据是从内部服务器加载的。

标签: ajax twitter-bootstrap popover


【解决方案1】:

第一次点击没有任何反应是正常的,因为在第一次点击时您设置了弹出框,一旦设置(在第一次点击中)弹出框将在下一次点击中显示,

如果你希望它在第一次点击时显示,你应该在 jquery 准备好时设置弹出框:

$( document ).ready(function() {
   switch(dataCheckTrecut[1]) {
        case '02': 
            var luna = "Februarie";
            break;
    }
    $(".checkRezolvataTrecut").popover({
        placement: "top",
        content: "<button class='btn btn-default mutaTrecut' style='width: 100px;'>" + luna + "</button><button class='btn btn-default mutaCurent' style='width: 100px;'>Luna curenta</button>",
        html: true

    });
});

【讨论】:

  • 是的,我后来知道了:)。抱歉迟到了。
猜你喜欢
  • 1970-01-01
  • 2012-05-30
  • 2012-06-24
  • 1970-01-01
  • 2014-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多