|
|
@@ -107,6 +107,35 @@
|
|
|
return defaultValue;
|
|
|
};
|
|
|
|
|
|
+ var compareObjects = function (objectA, objectB, compareLength) {
|
|
|
+ // Create arrays of property names
|
|
|
+ var objectAProperties = Object.getOwnPropertyNames(objectA),
|
|
|
+ objectBProperties = Object.getOwnPropertyNames(objectB),
|
|
|
+ propName = '';
|
|
|
+
|
|
|
+ if (compareLength) {
|
|
|
+ // If number of properties is different, objects are not equivalent
|
|
|
+ if (objectAProperties.length != objectBProperties.length) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var i = 0; i < objectAProperties.length; i++) {
|
|
|
+ propName = objectAProperties[i];
|
|
|
+
|
|
|
+ // If the property is not in the object B properties, continue with the next property
|
|
|
+ if ($.inArray(propName, objectBProperties) > -1) {
|
|
|
+ // If values of same property are not equal, objects are not equivalent
|
|
|
+ if (objectA[propName] !== objectB[propName]) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // If we made it this far, objects are considered equivalent
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+
|
|
|
var escapeHTML = function (text) {
|
|
|
if (typeof text === 'string') {
|
|
|
return text
|
|
|
@@ -2214,6 +2243,10 @@
|
|
|
};
|
|
|
|
|
|
BootstrapTable.prototype.refreshOptions = function (options) {
|
|
|
+ //If the objects are equivalent then avoid the call of destroy / init methods
|
|
|
+ if (compareObjects(this.options, options, false)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.options = $.extend(this.options, options);
|
|
|
this.trigger('refresh-options', this.options);
|
|
|
this.destroy();
|