fix: 修复 bootstrap-toggle 默认值问题
This commit is contained in:
parent
902afdfcdd
commit
833df4778e
|
@ -29,8 +29,7 @@
|
||||||
size: 'normal',
|
size: 'normal',
|
||||||
style: '',
|
style: '',
|
||||||
width: null,
|
width: null,
|
||||||
height: null,
|
height: null
|
||||||
defaultVal: ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Toggle.prototype.defaults = function() {
|
Toggle.prototype.defaults = function() {
|
||||||
|
@ -42,14 +41,11 @@
|
||||||
size: this.$element.attr('data-size') || Toggle.DEFAULTS.size,
|
size: this.$element.attr('data-size') || Toggle.DEFAULTS.size,
|
||||||
style: this.$element.attr('data-style') || Toggle.DEFAULTS.style,
|
style: this.$element.attr('data-style') || Toggle.DEFAULTS.style,
|
||||||
width: this.$element.attr('data-width') || Toggle.DEFAULTS.width,
|
width: this.$element.attr('data-width') || Toggle.DEFAULTS.width,
|
||||||
height: this.$element.attr('data-height') || Toggle.DEFAULTS.height,
|
height: this.$element.attr('data-height') || Toggle.DEFAULTS.height
|
||||||
defaultVal: this.$element.attr('data-default-val') || Toggle.DEFAULTS.defaultVal,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Toggle.prototype.render = function () {
|
Toggle.prototype.render = function () {
|
||||||
if(this.options.defaultVal === '') this.$element.prop('checked', true);
|
|
||||||
|
|
||||||
this._onstyle = 'btn-' + this.options.onstyle
|
this._onstyle = 'btn-' + this.options.onstyle
|
||||||
this._offstyle = 'btn-' + this.options.offstyle
|
this._offstyle = 'btn-' + this.options.offstyle
|
||||||
var size = this.options.size === 'large' ? 'btn-lg'
|
var size = this.options.size === 'large' ? 'btn-lg'
|
||||||
|
|
|
@ -500,6 +500,17 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extend bootstrap-toggle
|
||||||
|
if($.fn.bootstrapToggle) {
|
||||||
|
var toggle = $.fn.bootstrapToggle.Constructor;
|
||||||
|
var oldFunc = toggle.prototype.render;
|
||||||
|
toggle.prototype.render = function() {
|
||||||
|
var defaultVal = this.$element.attr('data-default-val') || '';
|
||||||
|
if(defaultVal === '') this.$element.prop('checked', true);
|
||||||
|
oldFunc.call(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (window.NProgress) {
|
if (window.NProgress) {
|
||||||
$(document).ajaxStart(function () {
|
$(document).ajaxStart(function () {
|
||||||
return NProgress.start();
|
return NProgress.start();
|
||||||
|
|
Loading…
Reference in New Issue