Reputation: 743
When I select "OK" in a component editor dialog, the component redraws itself, assuming I've got the _cq_editConfig.xml set up:
<cq:listeners
jcr:primaryType="cq:EditListenersConfig"
afteredit="REFRESH_SELF"/>
What I'd like to do is trigger "afteredit" via javascript. I've got a situation where the content has been changed and the author should have an updated view of the rendered component, but I don't know how to do this short of reloading the entire page or opening and closing the edit dialog. Presumably, the function that is represented by the "REFRESH_SELF" constant could be called, but I don't know how to trace the constant back to the function.
Does anyone know how to trigger afteredit from javascript?
Upvotes: 3
Views: 3297
Reputation: 866
the REFRESH_SELF constant is mapped to the method CQ.wcm.EditBase.refreshSelf. You can find its definition by going to /libs/cq/ui/widgets/source/widgets/wcm/EditBase.Listeners.js using crxde. To trigger it by javascript you need first to have the editable object and then call the method. For example:
var ed = CQ.WCM.getEditable('/path/to/the/object/in/page');
ed.refreshSelf();
Upvotes: 3
Reputation: 2563
@jwepurchase if all you want to do is reload the page after dialog edit or close, you can change the default "REFRESH_SELF" parameter of "afteredit" to "REFRESH_PAGE". It comes OOTB and it's unnecessary to write a script to achieve this functionality.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
cq:actions="[text: Banner Tile,edit,delete,insert]"
cq:dialogMode="floating"
cq:disableTargeting="{Boolean}true"
jcr:primaryType="cq:EditConfig">
<cq:listeners
jcr:primaryType="cq:EditListenersConfig"
afterdelete="REFRESH_PAGE"
afteredit="REFRESH_PAGE"/>
</jcr:root>
Reference -> Scroll down to the very end of this page https://docs.adobe.com/docs/en/cq/5-5/developing/components/edit_config.html
Upvotes: 0