Allow for namespacing of modal (and backdrop) window #286
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.
I made this change for my personal use a few days ago but figured it might be something others would want. Not sure if I implemented it correctly (but I tested it, and it works) as I am far from being a Javascript/jQuery expert.
This commit makes it possible to namespace your modal windows.
The use case for this is a page where you allow for clients to have custom html & css, but also have some static html/css of your own. Not namespacing your own css means that it could be overwritten by accident by the custom code.
I still wanted to use the Bootstrap elements so I simply added a class namespace inside the LESS files by wrapping all the css inside a new block:
This is very easy to do yourself and it works great, except that I can't use the vanilla JS with this because it places elements directly in the body of the page instead of the namespaced element.
With this commit, if you want a different parent element than the
document.body
, you pass it theparent
option.Now the modal will be positioned inside the element with class:
my_custom_namespace
on hiding/showing.If this is any good, and people are interested, perhaps it would be a good idea to port this functionality to the other JS files as well, but I haven't had a chance to check those out yet.