使小部件成为新小部件的子部件
情况是这样的。我的公司有一些小部件控件,这些控件已经实施了一年左右。我被要求向小部件添加“搜索功能”。到目前为止,小部件位于通过 cookie 将字段传递到其中的页面上。所以我的问题是,有没有办法创建新的小部件,在模板内引用旧的小部件并在运行时分配其属性?
这是一些示例
dojo.provide("company.billing.paymentSearch");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("company.test.inquiry");
dojo.declare(
"company.billing.paymentSearch",
[dijit._Widget, dijit._Templated],
{
token: "",
serviceUrl: "",
templatePath: dojo.moduleUrl(
"company.billing",
"templates/paymentSearch.html"
),
constructor: function(params, node) {
var self = this;
function onLoad() {
self.inquiryWidget.token = self.token;
self.inquiryWidget.serviceUrl = self.serviceUrl;
self.inquiryWidget.brandId = "";
self.inquiryWidget.agencyAccountNumber = "";
self.inquiryWidget.billingAccountNumber = "";
self.paymentWidget.token = self.token;
self.paymentWidget.serviceUrl = self.serviceUrl
}
dojo.addOnLoad(onLoad);
},
paymentSearch: function() {
var self = this;
self.inquiryWidget.billingAccountNumber = self.accountNumber;
}
}
);
,然后我的模板将是
<div>
<div style="float:left; width:20%; border: 1px solid #CCCCCC;">
<center>
Make a Payment
</center>
<br />
Account Number
<br />
<input style="width:85%" type="text" dojoattachpoint="accountNumber" />
<br />
<div class="searchButton">
</div>
</div>
<div style="float:right; width:79%">
<div id="inquiryWidget"
dojoType="company.billing.inquiry"
billingAccountNumber=""
agencyAccountNumber=""
brandId=""
waitPanelText="Loading ..."
showAccountSummary = "true"
showAccountHistory = "false"
token=""
serviceUrl="">
</div>
</div>
我想做的是在搜索按钮的 onclick 上,向 queryWidget 添加属性并启动它。这样的事情可能吗?
Here is the situation. My company has some widget controls that have been in place for a year or so. I am being asked to add a "search function" to the widget. Up to this point, the widget is on a page where the field is being passed into it via a cookie. So my question is this, is there a way to create new widget that inside the template it references the old widget and assigns its properties at run time?
Here is some sample
dojo.provide("company.billing.paymentSearch");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("company.test.inquiry");
dojo.declare(
"company.billing.paymentSearch",
[dijit._Widget, dijit._Templated],
{
token: "",
serviceUrl: "",
templatePath: dojo.moduleUrl(
"company.billing",
"templates/paymentSearch.html"
),
constructor: function(params, node) {
var self = this;
function onLoad() {
self.inquiryWidget.token = self.token;
self.inquiryWidget.serviceUrl = self.serviceUrl;
self.inquiryWidget.brandId = "";
self.inquiryWidget.agencyAccountNumber = "";
self.inquiryWidget.billingAccountNumber = "";
self.paymentWidget.token = self.token;
self.paymentWidget.serviceUrl = self.serviceUrl
}
dojo.addOnLoad(onLoad);
},
paymentSearch: function() {
var self = this;
self.inquiryWidget.billingAccountNumber = self.accountNumber;
}
}
);
then my template would be
<div>
<div style="float:left; width:20%; border: 1px solid #CCCCCC;">
<center>
Make a Payment
</center>
<br />
Account Number
<br />
<input style="width:85%" type="text" dojoattachpoint="accountNumber" />
<br />
<div class="searchButton">
</div>
</div>
<div style="float:right; width:79%">
<div id="inquiryWidget"
dojoType="company.billing.inquiry"
billingAccountNumber=""
agencyAccountNumber=""
brandId=""
waitPanelText="Loading ..."
showAccountSummary = "true"
showAccountHistory = "false"
token=""
serviceUrl="">
</div>
</div>
What I would like to do is on the onclick of the search button, add properties to the inquiryWidget and start it. Is something like this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过编程方式创建小部件,如下所示:
在模板中:
在 onLoad 函数中:
You can programatically create the widget like this:
in the template:
in the onLoad function: