简体   繁体   中英

Making widget a child of new widget

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?

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);
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM