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。

更多相关文章

  1. jQuery UI对话框调整大小关闭按钮
  2. 解析jquery实现回车键提交表单
  3. ASP.NET下使用jQuery UI下的Dialog,服务器端按钮无响应的问题。
  4. JQUERY中做表单验证,谁有带时间的日期选择控件?
  5. 用jquery 绑定一个按钮click事件后,第一次点击后,一切正常,第二次点
  6. 深入学习jQuery选择器系列第七篇——表单选择器
  7. jQuery Validate 表单验证插件
  8. 如何将表单转换成json通过AJAX传递?
  9. Yii - 加载ajax表单元素的用户端验证

随机推荐

  1. 相对布局相关属性
  2. [Android 博客]收集一些不错的,关于androi
  3. android应用自定义字体
  4. Android 控件使用参数集锦
  5. Android架构组件-Lifecycle
  6. Android API中文文档Button
  7. Android开发软件
  8. Android 资源聚集地
  9. android中TextView内容过长加省略号
  10. android 输入法出现挤压屏幕、android输