Soluzione UMD / AMD
Per quei ragazzi, che lo stanno facendo tramite UMD e compilano tramite require.js, c'è una soluzione laconica.
Nel modulo, che richiede tethercome dipendenza, che si carica Tooltipcome UMD, davanti alla definizione del modulo, basta inserire un breve frammento nella definizione di Tether:
// First load the UMD module dependency and attach to global scope
require(['tether'], function(Tether) {
// @todo: make it properly when boostrap will fix loading of UMD, instead of using globals
window.Tether = Tether; // attach to global scope
});
// then goes your regular module definition
define([
'jquery',
'tooltip',
'popover'
], function($, Tooltip, Popover){
"use strict";
//...
/*
by this time, you'll have window.Tether global variable defined,
and UMD module Tooltip will not throw the exception
*/
//...
});
Questo breve frammento all'inizio, in realtà, può essere applicato a qualsiasi livello più alto dell'applicazione, la cosa più importante - per invocarlo prima dell'uso effettivo dei bootstrapcomponenti con Tetherdipendenza.
// ===== file: tetherWrapper.js =====
require(['./tether'], function(Tether) {
window.Tether = Tether; // attach to global scope
// it's important to have this, to keep original module definition approach
return Tether;
});
// ===== your MAIN configuration file, and dependencies definition =====
paths: {
jquery: '/vendor/jquery',
// tether: '/vendor/tether'
tether: '/vendor/tetherWrapper' // @todo original Tether is replaced with our wrapper around original
// ...
},
shim: {
'bootstrap': ['tether', 'jquery']
}
UPD: In Boostrap 4.1 Stable hanno sostituito Tether , con Popper.js , consultare la documentazione sull'uso .