0
這是情況。我的公司有一些小部件控件已經存在了一年左右。我被要求添加一個「搜索功能」的小部件。到目前爲止,該小部件位於通過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,添加屬性的inquiryWidget並啓動它。是這樣的可能嗎?