When users change a setting in your app, update the app right away in the Wix Editor, but don’t change the app on the live site until the user publishes the site. Here’s how:
- Store two sets of data: Store both the data that’s visible in the Wix Editor and settings panel, and the data in the live site.
- Update the app in the Wix Editor immediately: Show the app with these latest changes in the Wix Editor (including the App Settings panel). There are two ways to do this, depending on whether the user changed the color/font, or other values like numbers/text/booleans.
- Wait for the user to publish the site before updating the app in the live site: Listen for the SITE_PUBLISHED event in the addEventListener method. When SITE_PUBLISHED is issued, update the app in the live site.
For color and font settings, use our custom wix-param attribute in both the website extension and in the App Settings panel.
When users change your app’s font or color, we’ll automatically update the app with these changes.
When users change your app’s settings (except the color and font), here’s how to update your app right away in the Wix Editor:
- Detect changes that the user makes in the App Settings panel:
- For Wix UI controls that use wix-param to save a number or boolean: listen for the STYLE_PARAMS_CHANGE event in the addEventListener method.
- For Wix UI controls that don’t use wix-param: use the onChange or onClick function.
- Update your database/backend server immediately: This is only relevant for UI controls that aren’t using wix-param. (If the UI control uses wix-param, the change is already saved in the Wix site – so there’s no need to update your server.)
- Show the changes in your app: For better user experience, don’t refresh your app. Here’s what to do instead:
- In the App Settings panel: Use triggerSettingsUpdatedEvent to send an update event to the extension.
- In the extension itself: Use addEventListener and listen for these events:
- SETTINGS_UPDATED event – for UI controls that don’t use wix-param
- STYLE_PARAMS_CHANGE – for UI controls that use wix-param
- Update the app with the new settings.