Ronald
Ronald

Reputation: 2917

how to pass string to cq dialog textfield

In cq dialog.xml I have the following textfield:

<foo
                        jcr:primaryType="cq:Widget"
                        name="./foo"
                        xtype="textfield"/>

In javascript, I have the following code:

function baar(){ var myString = "test";}

How to pass myString to the cq Dialog textfield?

Upvotes: 0

Views: 1273

Answers (1)

rakhi4110
rakhi4110

Reputation: 9281

You can use the setValue() method of the field to set the value.

function baar() {
    var myString = "test";
    var foo = this.findParentByType('dialog').getField('./foo');'
    foo.setValue(myString);
}

Kindly refer the widget api docs for more information on the available methods. A similar SO question already answers this.

Upvotes: 1

Related Questions