Had this error here:

// Fix collapsible links prevent the default click behavior.
      $(context).find('a[data-toggle="collapse"]').once('bootstrap-collapse', function () {
        $(this).on('click', function (e) {
          e.preventDefault();
        });
      });

fixed by changing ".once" to ".one"

seems to be ok for me.

Comments

markhalliwell’s picture

Issue summary: View changes
Status: Active » Fixed

Committed cf9978d to 7.x-3.x:

Issue #2122787 by Mark Carver, daveferrara1: Uncaught TypeError: Object [object Object] has no method 'once' line 17.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

netikseo’s picture

Hmm, I have the same error here (line 16):

Drupal.behaviors.bootstrap = {
    attach: function(context) {
      // Provide some Bootstrap tab/Drupal integration.
      $(context).find('.tabbable').once('bootstrap-tabs', function () {
        var $wrapper = $(this);
        var $tabs = $wrapper.find('.nav-tabs');
        var $content = $wrapper.find('.tab-content');
        var borderRadius = parseInt($content.css('borderBottomRightRadius'), 10);
        var bootstrapTabResize = function() {
          if ($wrapper.hasClass('tabs-left') || $wrapper.hasClass('tabs-right')) {
            $content.css('min-height', $tabs.outerHeight());
          }
        };
netikseo’s picture

Hmm, I have the same error here (line 16):

Drupal.behaviors.bootstrap = {
    attach: function(context) {
      // Provide some Bootstrap tab/Drupal integration.
      $(context).find('.tabbable').once('bootstrap-tabs', function () {
        var $wrapper = $(this);
        var $tabs = $wrapper.find('.nav-tabs');
        var $content = $wrapper.find('.tab-content');
        var borderRadius = parseInt($content.css('borderBottomRightRadius'), 10);
        var bootstrapTabResize = function() {
          if ($wrapper.hasClass('tabs-left') || $wrapper.hasClass('tabs-right')) {
            $content.css('min-height', $tabs.outerHeight());
          }
        };
netikseo’s picture

Any update on this? It's quite serious issue as other scripts on the page do not load with bootstrap as a theme...

burkeker’s picture

I can see the same issue here, too with 7.x-3.0. The bootstrap.js is loaded at the end of the page.

burkeker’s picture

I just found out the default 7.x-3.0 doesn't have this issue. I realised in my theme the jquery-1.7.1.min.js loaded twice which caused the error. So I believe it's not a problem of bootstrap.js.

rootical’s picture

I have the same problem in 7.x-3.0. Got it after theme update.
Using jQuery update with 1.7.
$(context).find('.tabbable').once('bootstrap-tabs', function () {
Any ideas?

robbyahn’s picture

I used bootstrap subtheme. After that I have the same issues.
If you use original bootstrap theme, it would be fine.
I just applied #1 solution

fixed by changing ".once" to ".one"
seems to be ok for me.

/js/bootstrap.js

Line.16
$(context).find('.tabbable').one('bootstrap-tabs', function () {

Line 119
$scrollableElement.one('bootstrap-anchors', function () {

Then works fine.

markhalliwell’s picture

$.one() is NOT the same as $.once().

$.one() - Binds a callback to an event that will only execute once.
$.once() - Immediately processes an element, but only once based on the string id passed (which adds -processed to the end of that ID and adds it as a class).

So in the example you provided above:

$(context).find('.tabbable').one('bootstrap-tabs', function () {

Line 119
$scrollableElement.one('bootstrap-anchors', function () {

You are binding to the DOM "events" bootstrap-tabs and bootstrap-anchors.... these aren't even events. They will never be called.

The reason this error happens is that some module somewhere is probably not including the /misc/jquery.once.js library (i.e. drupal_add_library('system', 'jquery.once'); in their custom page.

Also, this has since been fixed to always load this library if this theme is called:
http://cgit.drupalcode.org/bootstrap/tree/includes/alter.inc#n214