Closing Popup on Save

I’m looking for how to auto close the popup when the save button is clicked. Simple popup that has a reusable element in it that is the form. The save button is in the reusable element. The reusable element is the body of the popup.

Here’s a video showing my problem:

When I click SAVE, I want to close the popup, but all I see that I can hide are the reusable element objects. Hiding the group leaves the popup visible but now a blank white square in the middle of the screen. I could refresh the page, but I was hoping not to.

Can anyone tell me what obvious step I’m missing?
Gracias!
Buck

Hi there, @buckman… maybe the solution in this thread could work for you?

Hope this helps.

Best…
Mike

2 Likes

I thought I made my popup reusable already…so I guess I’m still missing some piece of understanding.

It looks like add_user_group_for_popup is a reusable element that contains only the form elements, and that reusable element is placed in the popup (which is why you can’t access the popup from the Save button’s workflow) as opposed to the popup itself being the reusable element.

1 Like

So…there is no parent reference when using a “reusable” element? It seems that’s what I’m running into.

I don’t use a lot of reusable elements, but I did some quick testing before posting my first reply, and I couldn’t find a way to do it. Maybe we’re both just missing something simple, but I don’t think so, and that’s why I did a search that produced the other thread.

1 Like

Thanks a bunch…at least it’s inobvious…that at least makes me feel better about it :slight_smile: thank you for giving a stab at it. I didn’t want to recreate the popup if I didn’t have to, but without any kind of parent inheritance, I suppose I’ll need to. Thanks for that article as well…If I can’t find a way to do it with a custom state…I’ll probably try that route. Thanks again!

No problem at all… and funny you mention the custom state because I had the same thought, and now my curiosity is piqued, so I might give it a try, too. :slight_smile:

1 Like

It worked!!! Sweet beans dude. It worked.

2 Likes

@buckman
@mikeloc

One way I think about reusables is that they do not know what page they are on. That is why to connect them with page elements gets tricky. Also, for a reusable to talk to a separate reusable gets tricky as well.

When popups are involved one way to go is to build the popup within the reusable element. You can even nest reusables … just like a vanilla Bubble app handles its header reusable with its signup/login reusable:

1 Like

This way you can find them easily within the flows of the “parent” reusable

1 Like

@buckman

This is a great watch (2 mins) by the good folks at AirDev … do not get misled by the name of the tutorial … I think it will shed a lot of light when dealing with RGs and opening menu options in rows through a reusable “hack” > Bubble Hack: How to have a vertical menu that shows up on click within a repeating group cell

1 Like

Here is the solution.

If you want to use a Reusable Element as the form body in a popup, you set a custom state on your reusable element and then you set up a trigger on that element at the form level. Here is what I did step by step:

  • I went to my Reusable Element and when the save button was closed, I added a custom state called “shouldClose” and set it to type “YES/NO” and a default of “YES” every time the save button is clicked
  • then, I went to my form that hosts the popup and added a custom trigger that runs every time that also checks for that state
  • step 1 of that custom event is to look for “shouldClose = YES” and if so to close the popup
  • step 2 of that custom event is to set the value to “NO” so it doesn’t run until called again
  • then, in my button that launches the popup, I set the state to “NO” there as well.

So, when the button is clicked, the state is NO and the popup stays open. When I click Save, it sets it to YES and it triggers the form-level event that happens to be the parent of the popup and that event closes it.

Works nicely!
Buck

2 Likes

Thanks @cmarchan and @mikeloc. I appreciate you both jumping in on this. Sometimes it just helps to be able to externalize these thoughts and frustrations in a lack of knowledge. I appreciate you both jumping in. Thanks again.
Buck

2 Likes

Sweet beans, indeed! That’s awesome, man… great work. Hmm, maybe one of us should circle back on the thread that I linked to and link to your solution here. I’m happy to do it (giving you all the credit, of course), but I’ll give you the right of first refusal. :slight_smile:

Go ahead. No sweat…thanks for asking tho.

1 Like

I’ll check it out - thanks!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.