【问题标题】:Bootstrap Popover Keep HTMLBootstrap Popover 保持 HTML
【发布时间】:2015-01-15 16:41:07
【问题描述】:

如何在重新初始化时保存弹出框内容?这是我的代码,弹出窗口包含一个表单。如果用户在填写一些信息后返回,我想保留表单值...

$(this).popover({
    html: true,
    trigger: 'manual',
    placement: 'bottom',
    content: function () {
        var $contents = $('#popover_template').html();
        return $contents;
    }
}).popover('toggle');

我不想要任何模式窗口等。即使重新打开弹出框,有没有办法保留表单的内容。

谢谢。

【问题讨论】:

  • 你能显示#popover_template 的标记吗?

标签: popover bootstrap-popover


【解决方案1】:

您可以使用“隐藏”事件来检测弹出框何时关闭,然后将其内容设置回您的#popover_template div。

$(this).popover({
  // your initialization code
}).popover('toggle')
  .on("hidden", function(e) {
     $('#popover_template').html($(this).html());
   });

参考文献

How to attach a function to popover dismiss event (Twitter Bootstrap)

Bootstrap modal popover hide on close

Bootstrap Popover - Save HTML on close

【讨论】:

  • 它会在打开弹出框而不是弹出框的按钮上显示文本。
  • 抱歉。只需将 $(this).html() 替换为弹出框中的 html。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-02
  • 1970-01-01
  • 2021-01-07
  • 1970-01-01
  • 2019-08-19
  • 2014-12-21
  • 2013-10-23
相关资源
最近更新 更多