Fix bug where last tab being removed, didn't update tabset input value

This commit is contained in:
Joe Cheng
2017-07-28 15:57:04 -07:00
committed by Barbara Borges Ribeiro
parent 91dbb0e77b
commit c090efd562
5 changed files with 40 additions and 22 deletions

View File

@@ -5101,14 +5101,23 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
},
setValue: function setValue(el, value) {
var self = this;
var anchors = $(el).find('li:not(.dropdown)').children('a');
anchors.each(function () {
if (self._getTabName($(this)) === value) {
$(this).tab('show');
return false; // Break out of each()
}
return true;
});
var success = false;
if (value) {
var anchors = $(el).find('li:not(.dropdown)').children('a');
anchors.each(function () {
if (self._getTabName($(this)) === value) {
$(this).tab('show');
success = true;
return false; // Break out of each()
}
return true;
});
}
if (!success) {
// This is to handle the case where nothing is selected, e.g. the last tab
// was removed using removeTab.
$(el).trigger("change");
}
},
getState: function getState(el) {
return { value: this.getValue(el) };
@@ -5117,7 +5126,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
if (data.hasOwnProperty('value')) this.setValue(el, data.value);
},
subscribe: function subscribe(el, callback) {
$(el).on('shown.bootstrapTabInputBinding shown.bs.tab.bootstrapTabInputBinding', function (event) {
$(el).on('change shown.bootstrapTabInputBinding shown.bs.tab.bootstrapTabInputBinding', function (event) {
callback();
});
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -11,15 +11,24 @@ $.extend(bootstrapTabInputBinding, {
return null;
},
setValue: function(el, value) {
var self = this;
var anchors = $(el).find('li:not(.dropdown)').children('a');
anchors.each(function() {
if (self._getTabName($(this)) === value) {
$(this).tab('show');
return false; // Break out of each()
}
return true;
});
let self = this;
let success = false;
if (value) {
let anchors = $(el).find('li:not(.dropdown)').children('a');
anchors.each(function() {
if (self._getTabName($(this)) === value) {
$(this).tab('show');
success = true;
return false; // Break out of each()
}
return true;
});
}
if (!success) {
// This is to handle the case where nothing is selected, e.g. the last tab
// was removed using removeTab.
$(el).trigger("change");
}
},
getState: function(el) {
return { value: this.getValue(el) };
@@ -29,7 +38,7 @@ $.extend(bootstrapTabInputBinding, {
this.setValue(el, data.value);
},
subscribe: function(el, callback) {
$(el).on('shown.bootstrapTabInputBinding shown.bs.tab.bootstrapTabInputBinding', function(event) {
$(el).on('change shown.bootstrapTabInputBinding shown.bs.tab.bootstrapTabInputBinding', function(event) {
callback();
});
},