我在链接点击上成功使用了引导弹出窗口。我在弹出框内有一些表单元素:文本字段,复选框和按钮。我可以使用jquery.live()附加按钮侦听器,但是在该按钮侦听器内部,我似乎无权访问正确的表单元素。如果我在控制台日志中找到它们,它们就存在,但是它们的值始终保持原始默认值,因此如果我去$('#txtComment')。val();不管我输入什么内容,字符串始终是相同的。
我是否可以查看任何示例,教程或源代码,以了解在引导弹出窗口内部使用任何形式的交互性的东西?
这是我设置弹出窗口的方式:
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));
那么我正在这样做以成功显示它:
this.commentLink.popover('show');
这是按钮单击功能:
commentSubmitClick: function(e){
console.log($('#txtComment').val());//always shows default text regardless of what I've actually typed in the field
}
最佳答案
语法已更改。 Kalin C Ringkvist的答案需要稍作修改:
var popover = this.commentLink.data('popover').tip();
注意方法
tip()
而不是$tip
。