Here is an update from internal Adobe community:
*************************
The trick for triggering JS methods is to add a unique class on your specific field.
<sample
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
class="cq-dialog-asset-path"
name="./sample"/>
Similarly on target field add class=”cq-dialog-dropdown-onchange-target"
I'm using Adobe Send & Track.
You can view "sample.js" at: https://files.acrobat.com/a/preview/68504f73-1ba4-42b7-804a-baea97cb9214
Add create a clientlib with this JS that has
categories="[cq.authoring.dialog]"
dependencies="[granite.jquery]"
Update:
More information:
The code below basically gets the value for the asset_type property that I defined in the dialog. That is just something we are using to determine what ID to get. Notice the listener.
$( ASSET_ID_CLASS ).on('change:value', function(event, payload) { var url = "/bin/freestyle-cms/wcm/getassetpath?type=" + assetType + "&id=" + payload.value; updateAssetPath( url ); // executing autopopulateonchange method after Asset path value is set. freestyle_ns.autoPopulateOnChange($(this)); });
<assetpath jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/hidden" assettype=“base_page” —> asset type. class="cq-dialog-asset-path" name="./ko:assetPath”/>