问题
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