Select to view content in your preferred language

Reopen popup with updated attributes

535
2
Jump to solution
05-24-2024 12:38 AM
WoHouYeng
New Contributor

I have been following this sample to create an popup with edit actions. However when I try to reopen the popup upon successful edits, the popup content is still showing the old value. I used the below code to reopen the popup.

layer.on("edits", e => {
    view.openPopup({
        features: e.updatedFeatures
    })

    editor.viewModel.cancelWorkflow();
});

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

We have something like the code below in our framework, and it works for this purpose:

//This is typically used when the popup's selected feature's attributes have changed, and the popup needs to reflect the new values
function reshowPopup(popup, graphic) {
	if (popup.selectedFeature == graphic) {
		var selectedFeatureIndex = popup.selectedFeatureIndex;
		var features = popup.features.concat([]);

		popup.features = features;
		popup.selectedFeatureIndex = selectedFeatureIndex;
	}
}

View solution in original post

2 Replies
JoelBennett
MVP Regular Contributor

We have something like the code below in our framework, and it works for this purpose:

//This is typically used when the popup's selected feature's attributes have changed, and the popup needs to reflect the new values
function reshowPopup(popup, graphic) {
	if (popup.selectedFeature == graphic) {
		var selectedFeatureIndex = popup.selectedFeatureIndex;
		var features = popup.features.concat([]);

		popup.features = features;
		popup.selectedFeatureIndex = selectedFeatureIndex;
	}
}
WoHouYeng
New Contributor

Hi @JoelBennett , sorry for the late reply. I managed to reopen the popup with the updated attributes with your solution after commenting the fetchFeatures property from the openPopup method. Thanks. 

reactiveUtils.when(
              () => editor.viewModel.state === "ready",
              () => {
                // Remove the editor and open the popup again
                view.ui.remove(editor);
                view.openPopup({
                  fetchFeatures: true,
                  shouldFocus: true
                });
              }
            );

 

 

0 Kudos