Skip to content

Instantly share code, notes, and snippets.

@THEtheChad
Last active November 5, 2015 15:55
Show Gist options
  • Save THEtheChad/53a45507fa629d9ff399 to your computer and use it in GitHub Desktop.
Save THEtheChad/53a45507fa629d9ff399 to your computer and use it in GitHub Desktop.
/**
* "reinitilizes" bootstrap on the jQuery
* object passed in
*
* @param {object} jQuery
* @param {string} url to retrieve the bootstrap source
*/
function bindBootstrap($target, source){
if(!source){
$target('script').each(function(){
if(!/bootstrap/i.test(this.src)) return;
source = this.src;
return false;
});
}
// Bootstrap can only be reinitialized
// by reloading the script
$target.get(source, function(raw_js){
// bootstrap binds itself to whatever
// library is assigned to the `jQuery`
// variable.
var temp = jQuery;
jQuery = $target;
$target('<script>')
.html(raw_js)
.appendTo('head');
// restore jQuery to the original version
jQuery = temp;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment