Hi there,
i've created an subtheme by using method 1 from the "subtheming how to".
I have included all js files from 'my_theme/bootstrap/' instead of using cdn, compiled the less-file.
Now there's an JS Error all the times, because of bootstrap/js/bootstrap.js is included all the time from themes/bootstrap/theme/alter.inc:
TypeError: $(...).find(...).once is not a function
I have to exclude this file in my own .info-file to get rid of the error:
exclude[js][] = 'sites/all/themes/bootstrap/js/bootstrap.js'
I've edited the howto, but please confirm this is really needed.
Comments
Comment #1
stephen.punwasi commentedIsn't this a very specific case scenario? If you're not using the bootstrap.js, you might as well just add the bootstrap.css to another theme.
You could also just comment it out of the .info file with a ";"
Comment #2
stephen.punwasi commentedComment #3
jehu commentedhm, i think if i include the bootstrap-files manually like in method 1 described, then the bootstrap.js is not needed. Why do you mean method 1 from howto is a specific scenario?
I don't want to use CDN, so i have to provide the files in my subtheme (so it's written in the how to).
that's the case, where i have to exclude bootstrap.js from the base theme, don't you think so?
Comment #4
andregriffin commentedThe bootstrap_subtheme.info.starterkit (should be renamed to bootstrap_subtheme.info) already has the js declared under the section of "Method 1". You just have to take off one semicolin from each line so that your "Method 1" looks like this.
When you turn on js aggregation, these files become equivalent to bootstrap.js. But here, you can comment out individual js features that you may not need.
Comment #5
jehu commentedYes, this is extactly the case where we have to exclude bootstrap.js from base theme, i think.
Comment #6
krystalcode commentedHi,
It doesn't look like this is the case, the file in the base theme sites/all/themes/bootstrap/js/bootstrap.js says:
"Provides general enhancements and fixes to Bootstrap's JS files."
It is not a file that belongs to the bootstrap library but it is a Drupal specific file from the boostrap module. It therefore is not the same with what you get from aggregating the sites/all/themes/bootstrap_subtheme/bootstrap/* files as these files are the original bootstrap library that has nothing to do with bootstrap.
Comment #7
markhalliwell@dimboz in #6 is correct. This is an enhancement JS file for Bootstrap -> Drupal integration. You're receiving this error because it sounds like the jquery.once library isn't loaded (for whatever reason). We'll likely need to patch the JS alter. Also it probably wouldn't hurt to rename the bootstrap.js file to drupal.bootstrap.js or something for clarity here.
Comment #8
markhalliwellCommitted d0b92f9 to 7.x-3.x:
Comment #11
ryan.armstrong commentedMoving this to the 8.x-3.x branch as it has been committed to that branch. Making sure the fix gets tested in the Drupal 8 release.
Comment #13
markhalliwellI'm just moving this back to 7.x. If this needs re-evaluation in 8.x, create a new issue.
Comment #14
bennyzen commentedWhile moving the call for scripts-inclusion out of head in html.tpl.php, bootstrap.js is included too early, causing a JS error. I've been trying to patch bootstrap_js_alter in alter.inc, since this seems the culprit for this misbehavior, but miserably failing at it. Maybe someone can point me into the right direction to avoid the inclusion from happening too early.
Comment #15
bennyzen commentedok, i found a solution for you guys using method 1: you do not really need the inclusion of bootstrap.js, like mentioned before by others. so i patched bootstrap_js_alter(), simply disabling the inclusion of bootstrap.js. Everything works great now.
Comment #16
gisleThis just bit me when using the latest snapshot of 7.x-3.x to create a sub-theme of Bootstrap, so it does not look like it has been fixed.
I am using the "less" starter kit (previously known as "method 1").
It looks like
jquery.once.jsis loaded on my site:but that does not seem to be enough - so I am changing the title.
Patching
bootstrap_js_alter()to not includebootstrap.js(as suggested in #15) fixed it for me.I also think the Drupal theme's
bootstrap.jsshould be renameddrupal.bootstrap.js(as suggested in #7) for clarity. It is awkward for debugging that it has the same file name as the main bootstrap library.Comment #17
markhalliwell@gisle, please create a new issue and reference closed ones. Hi-jacking existing closed issues makes it difficult to track when something has already been committed.
Comment #18
basvredelingThe += operator doesn't work reliably on all configurations. The attached patch proposes using array_replace() instead. If there are other users running into the following error, let's reopen this and rework the committed patch.
Comment #19
schiavone commentedSimilar issue with Bootstrap 7.x-3.6 js errors "TypeError: $context.find(...).once is not a function" causing other js not to load. Loading jquery 1.9 with jquery_update (1.9 or higher required). Load order looked fine. Added...
exclude[js][] = 'sites/all/themes/bootstrap/js/misc/_vertical-tabs.js'to .info file to remove error. A blunt solution until this issue gets sorted.
Comment #20
tamnv commentedI have same issue and my solution is exclude bootstrap.js on my custom theme.