Is there any other method rather than using the following code, for populating and binding the data at the same time:-
The other way to bind data to the fields could be:-
But, this code is not working. It's written at initialize event.
Even if have written the following at form:ready event, with this:-
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.
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.
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"/>