Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax Bootstrap Popover: Object #<Object> has no method 'popover'

I'm trying to build an Ajax Bootstrap Popover to display a page that contains a rating star system.

The javascript here work nice the first time. Then I have this error:

Uncaught TypeError: Object # has no method 'popover'

I'm not really good in jQuery, but I guess it seems to be due to the ajax call, but I can't find where the problem is.

$(".myRate")
        .popover({
            offset: 10,
            trigger: 'manual',
            animate: false,
            html: true,
            placement: 'top',
            template: '<div class="popover" onmouseover="$(this).mouseleave(function()  {$(this).hide(); });"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'

        });
$('.myRate').mouseenter(popoverDisplay);

popoverDisplay = function() {
var el = $(this);
var _data = el.attr('alt');
$.ajax({
     type: 'GET',
     url: 'notes.php',
     data: _data,
     cache: false,
     dataType: 'html',
     success: function(data) {
        el.attr('data-content', data);
        el.popover('show');
     }
  });
}

I don't get what I am doing wrong... Any idea ?

EDIT:

After searching, it seems that, it's the loaded pages which causes this error.

Exactly this part:

It seems that loading jquery-1.7.2.js make the bug because if I remove it, the error disapear. Problem: I can't delete it because without it jRating doesn't work anymore :/

like image 929
Vesper Bled Avatar asked Jul 08 '12 11:07

Vesper Bled


2 Answers

I had this problem after running the rails twitter bootstrap generator, then switching to bootstrap-sass.

It was caused by a filename collision because boostrap-sass references bootstrap.js instead of twitter/bootstrap, which clashes with the generated file.

Just rename the generated app/assets/javascripts/bootstrap.js.coffee to something else, eg app/assets/javascripts/bootstrap_and_overrides.js.coffee, and you're good to go.

like image 113
Zubin Avatar answered Oct 18 '22 09:10

Zubin


I had this problem because i was trying to use the jQuery from bootstrap while also importing jQuery from googleapis (like it says in http://railscasts.com/episodes/205-unobtrusive-javascript) if you're using bootstrap, you'll have jquery

like image 32
Hayk Saakian Avatar answered Oct 18 '22 09:10

Hayk Saakian