How to dynamically do the data binding (two-way binding as it happens when we do data binding through binding tab) through javascript?

nehadushyani

04-12-2019

Is there any other method rather than using the following code, for populating and binding the data at the same time:-

this.rawValue=xfa.resolveNode("$record.aaa.bbb").value;

The other way to bind data to the fields could be:-

Form.MyForm.bind.match="dataRef";

Form.MyForm.bind.ref="$record.aaa.bbb";

But, this code is not working. It's written at initialize event.

Even if have written the following at form:ready event, with this:-

$form.remerge();

What is the significance of this code? If this is not the right code, please describe any other javascript code/method.

In anyway, I want to bind the data with field as we do in binding tab in AEM Designer. By two way binding I mean that on changing the record the value for field gets updated and also the vice-versa should happen, as it happens when binding is done through binding tab.

Accepted Solutions (0)

Answers (2)

Answers (2)

radzmar

MVP

08-12-2019

You can use the setProperty property to bind various properties of a field or subform to a dataset which can be manipulated or replaced by scripting.

<!-- Set the fields font size to a value stored in the node Form.Style.FontSize under the default dataset "data". -->

<setProperty ref="$data.Form.Style.FontSize" target="font.size"/>

_Bruce_Robertson

MVP

05-12-2019

I don't think you can script against the binding properties.  If you can explain what you are trying to achieve, at a higher level, then we might be able to offer some alternatives.  If you are wanting to change the binding from one element in your xml to another you might be able to use predicts.

The remerge method takes the template DOM and data DOM and rebuilds the form DOM, so even if your scripting worked it would be reset by the remerge.

Regards

Bruce