Add Twitter Bootstrap Popover via Ajax, with Rails

旧巷老猫 提交于 2019-12-11 15:27:41

问题


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.

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

$("#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:

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

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>

Thank you for any help!


回答1:


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.



来源:https://stackoverflow.com/questions/11588645/add-twitter-bootstrap-popover-via-ajax-with-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!