Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
markhalliwellCommitted cf9978d to 7.x-3.x:
Comment #3
netikseo CreditAttribution: netikseo commentedHmm, I have the same error here (line 16):
Comment #4
netikseo CreditAttribution: netikseo commentedHmm, I have the same error here (line 16):
Comment #5
netikseo CreditAttribution: netikseo commentedAny update on this? It's quite serious issue as other scripts on the page do not load with bootstrap as a theme...
Comment #6
burkeker CreditAttribution: burkeker commentedI can see the same issue here, too with 7.x-3.0. The bootstrap.js is loaded at the end of the page.
Comment #7
burkeker CreditAttribution: burkeker commentedI 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.
Comment #8
rootical CreditAttribution: rootical commentedI 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?
Comment #9
robbyahn CreditAttribution: robbyahn commentedI 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.
Comment #10
markhalliwell$.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:
You are binding to the DOM "events"
bootstrap-tabs
andbootstrap-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