使小部件成为新小部件的子部件

发布于 2024-12-04 00:20:19 字数 2203 浏览 1 评论 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 上,向 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山川志 2024-12-11 00:20:19

您可以通过编程方式创建小部件,如下所示:

在模板中:

<div id="inquiryWidget" dojoAttachPoint="inquiryNode">

在 onLoad 函数中:

function onLoad() {
    self.inquiryWidget = new company.billing.inquiry({  
        token: self.token, 
        serviceUrl: self.serviceUrl 
    }, self.inquiryNode);
} 

You can programatically create the widget like this:

in the template:

<div id="inquiryWidget" dojoAttachPoint="inquiryNode">

in the onLoad function:

function onLoad() {
    self.inquiryWidget = new company.billing.inquiry({  
        token: self.token, 
        serviceUrl: self.serviceUrl 
    }, self.inquiryNode);
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文