在引导程序弹出窗口中使用交互式元素
I am successfully using a bootstrap popover on a link click. I have some form elements inside the popover: a textfield, checkbox and a button. I'm able to attach a button listener using jquery.live(), but inside that button listener I don't seem to have any access to the correct form elements. They exist if I trace them out in a console log, but their values always remain the original defaults, so if I go $('#txtComment').val(); the string is always the same, regardless of what I put into the field.
我在链接点击上成功使用了bootstrap popover。我在popover中有一些表单元素:textfield,checkbox和button。我可以使用jquery.live()附加一个按钮监听器,但在该按钮监听器中,我似乎没有任何访问正确的表单元素的权限。如果我在控制台日志中跟踪它们,它们就存在,但它们的值始终保持原始默认值,所以如果我去$('#txtComment')。val();无论我放入字段中,字符串总是相同的。
Are there any examples, tutorials or source code I could look at of something that is using any kind of interactivity inside a bootstrap popover?
是否有任何示例,教程或源代码我可以看一下在引导程序弹出窗口中使用任何类型的交互性的东西?
this is how I'm setting up the popover:
这就是我设置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));
then I'm doing this to successfully show it:
然后我这样做是为了成功展示它:
this.commentLink.popover('show');
and this is the button click function:
这是按钮点击功能:
commentSubmitClick: function(e){
console.log($('#txtComment').val());//always shows default text regardless of what I've actually typed in the field
}
4 个解决方案
#1
19
The syntax changed. The answer of Kalin C Ringkvist needs to be slightly modified:
语法改变了。 Kalin C Ringkvist的答案需要稍加修改:
var popover = this.commentLink.data('popover').tip();
Note the method tip()
instead of $tip
.
注意方法tip()而不是$ tip。
更多相关文章
- jQuery UI对话框调整大小关闭按钮
- 解析jquery实现回车键提交表单
- ASP.NET下使用jQuery UI下的Dialog,服务器端按钮无响应的问题。
- JQUERY中做表单验证,谁有带时间的日期选择控件?
- 用jquery 绑定一个按钮click事件后,第一次点击后,一切正常,第二次点
- 深入学习jQuery选择器系列第七篇——表单选择器
- jQuery Validate 表单验证插件
- 如何将表单转换成json通过AJAX传递?
- Yii - 加载ajax表单元素的用户端验证