小编Kal*_*ist的帖子

在引导程序弹出窗口中使用交互式元素

我在链接点击上成功使用了bootstrap popover.我在popover中有一些表单元素:textfield,checkbox和button.我能够使用jquery.live()附加一个按钮监听器,但在该按钮监听器中,我似乎没有任何正确的表单元素的访问权限.如果我在控制台日志中跟踪它们,它们就存在,但它们的值始终保持原始默认值,所以如果我去$('#txtComment').val(); 无论我放入字段中,字符串总是相同的.

是否有任何示例,教程或源代码我可以看一下在引导程序弹出窗口中使用任何类型的交互性的东西?

这就是我设置popover的方式:

this.commentLink.popover({
  trigger: 'manual',
  placement: 'right',
  html : true,
  content: function () {
    return $('#commentPopout').html();
  }
}).popover('hide');

//jquery.on won't work here so we use live
$('#btnSubmitComment').live('click', this.proxy(this.commentSubmitClick));
Run Code Online (Sandbox Code Playgroud)

然后我这样做是为了成功展示它:

this.commentLink.popover('show');
Run Code Online (Sandbox Code Playgroud)

这是按钮点击功能:

commentSubmitClick: function(e){
  console.log($('#txtComment').val());//always shows default text regardless of what I've actually typed in the field
}
Run Code Online (Sandbox Code Playgroud)

jquery popover twitter-bootstrap

18
推荐指数
2
解决办法
2万
查看次数

标签 统计

jquery ×1

popover ×1

twitter-bootstrap ×1