diff --git a/bi/core.js b/bi/core.js index e7aa96ebc..75319bb31 100644 --- a/bi/core.js +++ b/bi/core.js @@ -351,12 +351,9 @@ BI.Factory = { return {} }, - init: function () { - }, // _init is an empty function by default. Override it with your own // initialization logic. _init: function () { - this.init(); }, // Return a copy of the model's `attributes` object. @@ -1204,9 +1201,9 @@ BI.Factory = { setVisible: function (visible) { this.options.invisible = !visible; if (visible) { - this.element.show(); + this.element.css("display", ""); } else { - this.element.hide(); + this.element.css("display", "none"); } }, @@ -4750,11 +4747,15 @@ BI.Widget = BI.inherit(BI.OB, { this.purgeListeners(); } });BI.Model = BI.inherit(BI.M, { + props: {}, + init: null, + destroyed: null, + _defaultConfig: function () { - return { + return BI.extend({ "default": "just a default", "current": void 0 - } + }, this.props) }, _static: function () { @@ -4788,6 +4789,7 @@ BI.Widget = BI.inherit(BI.OB, { this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30); this._F = []; + this.init && this.init(); }, toJSON: function () { @@ -5230,8 +5232,16 @@ BI.Widget = BI.inherit(BI.OB, { */ BI.View = BI.inherit(BI.V, { + //生命周期函数 + beforeCreate: null, + + created: null, + + destroyed: null, + _init: function () { BI.View.superclass._init.apply(this, arguments); + this.beforeCreate && this.beforeCreate(); var self = this; this.listenTo(this.model, "change:current", function (obj, val) { if (BI.isNotNull(val) && val.length > 0) { @@ -5275,7 +5285,8 @@ BI.View = BI.inherit(BI.V, { return f.apply(this, arguments); }, self); } - }) + }); + this.created && this.created(); }, change: function (changed, prev) { @@ -5720,7 +5731,7 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.off(); }, @@ -5730,14 +5741,10 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.remove(); this.trigger(BI.Events.DESTROY); this.off(); - }, - - destroyed: function () { - } });(function () { diff --git a/docs/core.js b/docs/core.js index e87cd01c6..ddbf75f1a 100644 --- a/docs/core.js +++ b/docs/core.js @@ -11493,12 +11493,9 @@ BI.Factory = { return {} }, - init: function () { - }, // _init is an empty function by default. Override it with your own // initialization logic. _init: function () { - this.init(); }, // Return a copy of the model's `attributes` object. @@ -12346,9 +12343,9 @@ BI.Factory = { setVisible: function (visible) { this.options.invisible = !visible; if (visible) { - this.element.show(); + this.element.css("display", ""); } else { - this.element.hide(); + this.element.css("display", "none"); } }, @@ -14752,11 +14749,15 @@ BI.Widget = BI.inherit(BI.OB, { this.purgeListeners(); } });BI.Model = BI.inherit(BI.M, { + props: {}, + init: null, + destroyed: null, + _defaultConfig: function () { - return { + return BI.extend({ "default": "just a default", "current": void 0 - } + }, this.props) }, _static: function () { @@ -14790,6 +14791,7 @@ BI.Widget = BI.inherit(BI.OB, { this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30); this._F = []; + this.init && this.init(); }, toJSON: function () { @@ -15232,8 +15234,16 @@ BI.Widget = BI.inherit(BI.OB, { */ BI.View = BI.inherit(BI.V, { + //生命周期函数 + beforeCreate: null, + + created: null, + + destroyed: null, + _init: function () { BI.View.superclass._init.apply(this, arguments); + this.beforeCreate && this.beforeCreate(); var self = this; this.listenTo(this.model, "change:current", function (obj, val) { if (BI.isNotNull(val) && val.length > 0) { @@ -15277,7 +15287,8 @@ BI.View = BI.inherit(BI.V, { return f.apply(this, arguments); }, self); } - }) + }); + this.created && this.created(); }, change: function (changed, prev) { @@ -15722,7 +15733,7 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.off(); }, @@ -15732,14 +15743,10 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.remove(); this.trigger(BI.Events.DESTROY); this.off(); - }, - - destroyed: function () { - } });(function () { diff --git a/src/core/model.js b/src/core/model.js index 7c8ced029..a45cfb5e1 100644 --- a/src/core/model.js +++ b/src/core/model.js @@ -1,9 +1,13 @@ BI.Model = BI.inherit(BI.M, { + props: {}, + init: null, + destroyed: null, + _defaultConfig: function () { - return { + return BI.extend({ "default": "just a default", "current": void 0 - } + }, this.props) }, _static: function () { @@ -37,6 +41,7 @@ BI.Model = BI.inherit(BI.M, { this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30); this._F = []; + this.init && this.init(); }, toJSON: function () { diff --git a/src/core/mvc/fbi.js b/src/core/mvc/fbi.js index a00ec13c7..948b2b143 100644 --- a/src/core/mvc/fbi.js +++ b/src/core/mvc/fbi.js @@ -300,12 +300,9 @@ return {} }, - init: function () { - }, // _init is an empty function by default. Override it with your own // initialization logic. _init: function () { - this.init(); }, // Return a copy of the model's `attributes` object. @@ -1153,9 +1150,9 @@ setVisible: function (visible) { this.options.invisible = !visible; if (visible) { - this.element.show(); + this.element.css("display", ""); } else { - this.element.hide(); + this.element.css("display", "none"); } }, diff --git a/src/core/view.js b/src/core/view.js index f5e5f2311..5912819cd 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -5,8 +5,16 @@ */ BI.View = BI.inherit(BI.V, { + //生命周期函数 + beforeCreate: null, + + created: null, + + destroyed: null, + _init: function () { BI.View.superclass._init.apply(this, arguments); + this.beforeCreate && this.beforeCreate(); var self = this; this.listenTo(this.model, "change:current", function (obj, val) { if (BI.isNotNull(val) && val.length > 0) { @@ -50,7 +58,8 @@ BI.View = BI.inherit(BI.V, { return f.apply(this, arguments); }, self); } - }) + }); + this.created && this.created(); }, change: function (changed, prev) { @@ -495,7 +504,7 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.off(); }, @@ -505,13 +514,9 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.remove(); this.trigger(BI.Events.DESTROY); this.off(); - }, - - destroyed: function () { - } }); \ No newline at end of file