2

I am having trouble with getting my bootstrap popover to work correctly in my rails application. I have tried solutions to other questions with no success.

Currently in my HTML I have:

<i class="icon-exclamation-sign" id="info" rel="popover" data-content="some info"></i>

and

<script>  
$(function () {
  $(".icon-exclamation-sign").popover();  
});  
</script>

My application.js looks like:

//= require jquery
//= require jquery_ujs
//= require bootstrap-datepicker
//= require_tree .
//= require bootstrap-tooltip
//= require bootstrap-popover

and my application.css looks like:

/*
*= require_tree .
*= require bootstrap-datepicker
*/

And I get the error: Uncaught TypeError: Object [object Object] has no method 'popover' when loading the page. What am I doing wrong?

EDIT: Also I have tried just using require bootstrap instead of tooltip and popover in my application.js with no luck.

user1676463
  • 65
  • 1
  • 8

3 Answers3

3

Try putting the code under /app/assets/javascripts/ and see if it changes anything.

/javascripts/some_name.js

$(document).ready(function() {
  $(".icon-exclamation-sign").popover();
});

Actually I think the problem is that //= require_tree . should be last, try the following:

//= require jquery
//= require jquery_ujs
//= require bootstrap-datepicker
//= require bootstrap-tooltip
//= require bootstrap-popover
//= require_tree .

Same for application.css

mind.blank
  • 4,820
  • 3
  • 22
  • 49
1

I finally figured out the problem by following the advice here.

I had to add the line to my development.rb file:

config.serve_static_assets = false
Community
  • 1
  • 1
user1676463
  • 65
  • 1
  • 8
0

Try the rake assets:clean command. This should delete any legacy JS/CSS that hasn't picked up your changes.

With most browsers you can view the source of the page to check the versions of the the asset files it's using, see if your changes are being picked up in there and if they aren't, this might work.