From 900588428b96198d12deb3829957a7dd6a61447a Mon Sep 17 00:00:00 2001 From: git Date: Sat, 31 Jul 2021 11:56:26 +0800 Subject: [PATCH] =?UTF-8?q?loader=E7=9A=84context=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=8E=BB=E6=8E=89=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/fix/fix.compact.ie.js | 18 ++-- dist/fix/fix.compact.js | 26 +++--- examples/loader-context.html | 124 +++++++++++++++++++++++++++ examples/tab-context.html | 7 ++ src/base/combination/group.button.js | 2 +- src/core/2.base.js | 2 +- 6 files changed, 155 insertions(+), 24 deletions(-) create mode 100644 examples/loader-context.html diff --git a/dist/fix/fix.compact.ie.js b/dist/fix/fix.compact.ie.js index 152f94f89..ab949b5bd 100644 --- a/dist/fix/fix.compact.ie.js +++ b/dist/fix/fix.compact.ie.js @@ -93,15 +93,15 @@ } } - _.each(["populate", "addItems", "prependItems"], function (name) { - var old = BI.Loader.prototype[name]; - BI.Loader.prototype[name] = function () { - BI.Widget.pushContext(this); - var result = old.apply(this, arguments); - BI.Widget.popContext(); - return result; - }; - }); + // _.each(["populate", "addItems", "prependItems"], function (name) { + // var old = BI.Loader.prototype[name]; + // BI.Loader.prototype[name] = function () { + // BI.Widget.pushContext(this); + // var result = old.apply(this, arguments); + // BI.Widget.popContext(); + // return result; + // }; + // }); function createStore () { var needPop = false; diff --git a/dist/fix/fix.compact.js b/dist/fix/fix.compact.js index 1fa5e2972..8b635c0c1 100644 --- a/dist/fix/fix.compact.js +++ b/dist/fix/fix.compact.js @@ -97,19 +97,19 @@ } } - _.each(["populate", "addItems", "prependItems"], function (name) { - var old = BI.Loader.prototype[name]; - BI.Loader.prototype[name] = function () { - BI.Widget.pushContext(this); - try { - var result = old.apply(this, arguments); - } catch (e) { - console.error(e); - } - BI.Widget.popContext(); - return result; - }; - }); + // _.each(["populate", "addItems", "prependItems"], function (name) { + // var old = BI.Loader.prototype[name]; + // BI.Loader.prototype[name] = function () { + // BI.Widget.pushContext(this); + // try { + // var result = old.apply(this, arguments); + // } catch (e) { + // console.error(e); + // } + // BI.Widget.popContext(); + // return result; + // }; + // }); function createStore () { var needPop = false; diff --git a/examples/loader-context.html b/examples/loader-context.html new file mode 100644 index 000000000..72695cc9f --- /dev/null +++ b/examples/loader-context.html @@ -0,0 +1,124 @@ + + + + + + + + +
+ + + diff --git a/examples/tab-context.html b/examples/tab-context.html index 33edfd13c..9e7cf33ea 100644 --- a/examples/tab-context.html +++ b/examples/tab-context.html @@ -39,13 +39,20 @@ var Child = BI.inherit(BI.Widget, { setup: function () { + var label var store = BI.useStore(function () { return BI.Models.getModel("demo.child_model"); }); + BI.watch("text", function (text) { + label.setText(text) + }); return { render: function () { return { type: "bi.label", + ref: function (_ref) { + label = _ref; + }, text: store.model.text }; } diff --git a/src/base/combination/group.button.js b/src/base/combination/group.button.js index 3a13f6d6e..d9642d696 100644 --- a/src/base/combination/group.button.js +++ b/src/base/combination/group.button.js @@ -40,7 +40,7 @@ BI.ButtonGroup = BI.inherit(BI.Widget, { var o = this.options; return BI.createWidgets(BI.createItems(items, { type: "bi.text_button" - })); + }), this); }, _btnsCreator: function (items) { diff --git a/src/core/2.base.js b/src/core/2.base.js index c9e7b1699..3aa8a155b 100644 --- a/src/core/2.base.js +++ b/src/core/2.base.js @@ -84,7 +84,7 @@ if (!_global.BI) { options || (options = {}); } return BI.map(BI.flatten(items), function (i, item) { - return BI.createWidget(item, BI.deepClone(options)); + return BI.createWidget(item, BI.deepClone(options), context); }); },