After updating from bootstrap-table v. 1.14.2 to bootstrap-table v. 1.15.2 I got this error
Uncaught TypeError: $('#table').bootstrapTable is not a function
Note:
I found that the problem is that bootstrapTable
function doesn't end up in jQuery elements prototype. I looked to the dist folder in node_modules/bootstrap-table/dist/bootstrap-table.js and saw this (for v 1.15.2):
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
(global = global || self, global.BootstrapTable = factory(global.jQuery));
}(this, function ($) {
// do some stuff
$.fn.bootstrapTable = function (option, ...args) { ... }
// do some other stuff
}));
while for version for v 1.14.2 it looked like this:
(function (global, factory) {
if (typeof define === "function" && define.amd) { define([], factory); }
else if (typeof exports !== "undefined") { factory(); }
else {
var mod = {
exports: {}
};
factory();
global.bootstrapTable = mod.exports;
}
})(this, function () {
// do some stuff
$.fn.bootstrapTable = function (option, ...args) { ... }
// do some other stuff
});
The thing is that in version 1.15.2. we require new instance of jQuery, so when I use $('#table').bootstrapTable
, $
here is different form the same variable in bootstrap-table.js
, but in 1.14.2 we use global $ variable, so when I use $('#table').bootstrapTable
, $
is the same object as in in bootstrap-table.js
, so we have our bootstrapTable
function. Can I somehow resolve this issue?