情况如下。我的公司有一些小工具控件已经存在了一年左右。我被要求在小部件中添加“搜索功能”。到目前为止,窗口小部件位于通过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>
我想要做的是点击搜索按钮,向inquiryWidget添加属性并启动它。这样的事情可能吗?
答案 0 :(得分:0)
您可以这样编程创建窗口小部件:
在模板中:
<div id="inquiryWidget" dojoAttachPoint="inquiryNode">
onLoad函数中的:
function onLoad() {
self.inquiryWidget = new company.billing.inquiry({
token: self.token,
serviceUrl: self.serviceUrl
}, self.inquiryNode);
}