Fix carousel and other Bootstrap JS plugins broken by jQuery noConfli… - #171
Merged
Merged
Conversation
…ct order The sphinx_bootstrap_theme package loads scripts as: jquery, jquery-fix.js, bootstrap.min.js, bootstrap-sphinx.js. Its bundled jquery-fix.js calls jQuery.noConflict(true), which strips both window.jQuery and window.$ before bootstrap.min.js loads. bootstrap.min.js grabs the global jQuery symbol to attach its plugins, so it throws immediately and none of them (carousel, dropdown, collapse, ...) ever get attached. Override the theme's static jquery-fix.js (Sphinx lets project html_static_path files overwrite theme static files of the same name) to call noConflict() without removing window.jQuery, which keeps bootstrap.min.js working while bootstrap-sphinx.js still uses window.$jqTheme as before. Fixes #146
Member
|
Nice! Thanks for looking in this quite old issue 🙂. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The theme's bundled
jquery-fix.jscallsjQuery.noConflict(true)beforebootstrap.min.jsloads, wipingwindow.jQueryand breaking every Bootstrap JS plugin (carousel, dropdowns, ...).This overrides that file (Sphinx lets project static files shadow theme static files) to use
noConflict()instead, which keepswindow.jQuerydefined forbootstrap.min.jswhile leavingbootstrap-sphinx.js's behavior unchanged.Verified locally with
sphinx-build: no more console error, and the carousel auto-advances and responds to manual prev/next/indicator clicks.Fixes #146
Done with Sonnet 5