How can I trigger a module's modal, but not on page load

Hi Victoria/the community,

I have a module that we want to be able to reuse which is a modal form. I have used the technique you suggest here to enable us to trigger the modal to open from outside the module. This works fine (if a pretty dodgy workaround), but it also has the side effect that it also triggers on page load (as noted in the "Query JSON with SQL" itself: "Query is automatically executed when the page first loads or when a variable it depends on updates."). It is not functional to have modals appearing on page load when a user doesn't expect or want to see them. How can we either suppress the opening on page load, or find another way to open a modal in a module from the hosting app?

Thanks,

Joshua

I have an equally dodgy way of accomplishing that and a simpler but less flexible method.

I have a variable (say runQuery) that is set it's default to true. I the the Disable query param (Advanced tab) in the JSON SQL query to {{runQuery.value}}. It will not trigger onLoad.

Then in the Modal Open event (or any other place that is appropriate for you) I set the variable to false. Then the query will trigger. You can also set the variable back to true in the Modal Close event so it will not run until the modal is reopened.

Now that gives you full control of when the query will run, but if you just want to disable the query when the modal is not shown then simply set the Disable query prop to {{!modal1.opened}}.

1 Like