Fetching Data from Another Custom Property Editor ...
# help-with-umbraco
d
Hello! I'm currently developing a custom property editor that includes a function requiring fetching data from another custom property editor. Both of these editors are located within the same tab. In my previous work, I've used eventsService (onsave) for communication between custom property editors within the same document type, and Backoffice API Controllers for those in different document types. In this case, I want to get the value from the other Custom Property Editor immediately upon the controller loading. What is the most efficient method for fetching data from a custom property editor located within the same tab? Specifically, I'm interested in retrieving the $scope.model.value of the other property editor. Any insights or recommendations would be greatly appreciated!
l
I do this in my Contentment package for the Data List preview (on a Data Type config). It's using the
eventsService
as you mentioned. It'll
emit
a custom event on initial load (after a slight
$timeout
), sending the
$scope.model
payload... https://github.com/leekelleher/umbraco-contentment/blob/4.5.1/src/Umbraco.Community.Contentment/DataEditors/ConfigurationEditor/configuration-editor.js#L208 I also fire it from a
setDirty()
function, to keep the values in sync. Then on the other side, it'll pick up the event and act accordingly... https://github.com/leekelleher/umbraco-contentment/blob/4.5.1/src/Umbraco.Community.Contentment/DataEditors/DataList/data-list.preview.js#L48 Hope this helps.
d
Apologies for the delayed response, but thank you so much, Lee! This solved my issue. While I was considering a similar approach, the idea of using a timeout didn't occur to me, and that turned out to be the key. Everything is working as expected now. Thanks again
16 Views