通过带有Rails的Ajax添加Twitter Bootstrap Popover [英] Add Twitter Bootstrap Popover via Ajax, with Rails

查看:105
本文介绍了通过带有Rails的Ajax添加Twitter Bootstrap Popover的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过带有Rails的Ajax调用添加弹出窗口.我在萤火虫中看到内容可以很好地加载,但是弹出窗口没有加载.

I'm trying to add a popover via an ajax call with rails. I see in firebug that the content loads fine, but the popover isn't loading.

所有其他弹出窗口都可以在页面上使用,如果我重新加载页面,则弹出窗口也可以使用...但是在ajax调用上它不起作用.我想念什么?

All other popovers work on the page, and if I reload the page, the popover works too...but it just doesn't work on the ajax call. What am I missing?

update.js

update.js

$("#new-pins").append("<div class='pinimage' data-original-title=''><img src='/images/<%= @changes[0] %>.png' class='pinimage' data-content='hello' data-original-title=''></a></div>")

show.html popover javascript:

show.html popover javascript:

<script>
$(function () {
    $('.pinimage').popover({ html : true });
});
</script>

这是ajax调用后加载的内容:

Here's what loads after the ajax call:

<div class="pinimage" data-original-title="">
   <img class="pinimage" data-original-title="" data-content="hello" src="/images/card.png">
</div>

谢谢您的帮助!

推荐答案

我有一个类似的

I had a similiar issue and finally got it to work when I realized that I was calling the jquery on document load but I had to call it again in the .js.erb file.

这篇关于通过带有Rails的Ajax添加Twitter Bootstrap Popover的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆