How to close modal dialog windows from javascript - oracle-apex-5.1

I have a page from which modal dialog page gets opened. After page is opened, the user makes some selections and clicks on the button and some javascript gets executed. After it is done, I need to close the modal page. I tried window.close() but it did not work. How can I close the modal dialog page from javascript?

Try this:
apex.navigation.dialog.close(true)
https://docs.oracle.com/cd/E59726_01/doc.50/e39149/javascript_api.htm#AEAPI30096

I have rarely seen the documentation on the method below. I had to read a book to find out.
Try this:
redirect to URL:
javascript:closeModal();
You can also pass the modal parameter if necessary:
javascript:closeModal('P2_HELP_MODAL');
You can also open the same way:
javascript:openModal('P2_HELP_MODAL');

Related

Slack modal is not cleared from a Updated view

I have modal flow in my Slack App. I have some issues with the end of the flow however.
Basic idea of the flow. You get a Modal, you do a selection, you get another modal, you perform an action and then Modal disappears.
I have tried two different ways both with problems but with different result
Flow 1: response_action: "update"
You press a button on home tab that opens a modal with bot.views.open
You make a selection
In the response I send {response_action: 'update', view: }
User gets the new Modal without any errors. They then click a button.
Now I would like the modal to disappear. So on the result of the action I send {response_action: 'clear'}
Nothing happens :(. I would like the modal to disappear of course :)
Flow 2: bot.views.update
You press a button on home tab that opens a modal with bot.views.open
You make a selection
I create the same view as above but I run bot.views.update{view_id: , view: }
New view comes up however it has an error in the top: We had some trouble connecting. Try again?
Now I would like the modal to disappear. So on the result of the action I send {response_action: 'clear'}
Nothing happens :(. I would like the modal to disappear of course :)
So second flow has annoying error but same result with not disappearing.
Feels like Im missing something here.
Somebody have an Idea what Im missing?

Modal dialog - refresh the parent page on close modal dialog or submit button

Using Apex 5.1.3
I have everyting working, but I have a requreimet to refresh the entire page (parent page) on the close of the modal page or press submit button.
I have tried quite a few things in dynamic actions on the parent page etc, but nothing is working.
How can I get the parent page to fully refresh when the modal dialog is submitted and closed.
Your help would be most appreciated.
Regards,
Morshed
You could either place a branch after processing on your modal that redirects to the parent page, or create a dynamic action 'on dialog close' on the button/region that invokes the dialog page, which then submits/refreshes the page.
If you think 'nothing is working', put APEX in debug mode, open your browser console, and check if the dynamic actions are actually firing.

Facebox Fails When Loaded via AJAX

I have a very simple HTML page at http://bit.ly/1eaSnKt
The first line is a functioning Facebox link. Note that, when clicked, it opens the FaceBox popup perfectly.
The second line is a similar link, but exists on a different HTML page which is pulled via AJAX (see source). For some reason, when clicked, it fails to open the FaceBox popup. Does anyone have a clue why this is failing? Thanks.
When your page loads, on Document ready, you are attaching the behaviors to the items in the page.
With the Ajax load, it loads the items after the document is ready, and there jQuery has attached the behaviors... missing your new content.
You need to attach those behaviors after the ajax is successful.
So after the ajax load, use a callback, or a closure to do this
$('a[rel*=facebox]').facebox({
loading_image : 'facebox/loading.gif',
close_image : 'facebox/closelabel.gif'
})
Hope that makes sense.
Thanks all. I actually found the solution here - https://github.com/dator/facebox/commit/5ce6a75927d81b9fff1eeff9b933f0ad93f12801

Remain within magnific popup

I have an ajax popup working nicely with Magnific Popup. However the page that I am loading into the popup via the ajax call contains a hyperlink.
The only contents of the page is:
test
When I click on the "test" link "anotherpage.html" loads in the original parent window.
Is it possible for the page that this link points to to be loaded in the same popup window?
you can achive this effect by following these steps:
download the html page with jQuery into a temporay variable
from the variable get the link address
send Magnific Popup the link you want to display in the first place
for the first part, you can you this great post on stackoverflow: How do I load html into a variable with jquery
for the second task, all you need is to query the first (and only) link in your html page and get it's href attribute:
var target = $('a:eq(0)').attr('href');
now that 'target' variable stores the requested url - send it over to Magnific Popup
include a empty iframe in the popup.
create a function onclick in Test for change the src of iframe and hide or destroy the old thinks in the popup,

Wicket: Modal Windows and callback functionality

I have a modal window that shows a panel which contains a form that has some textfields and a submit button
on submit an insert into the database occurs and then I have some ajax behaviour that i want to activate on the modal windows containing page on click of the button.
So flow is at present:
click link
modal window appears
user fills out form
user submits form
form data persisted to db
modal window closes
I need it to do this in addition:
activate some ajax behaviour on the page that contains the panel
any help on how best to do this in the wicket way is appreciated.
I resolved this by passing an instance of the page containing the panel to the panel (i.e. - in the constructor), then calling a method on the page from the panel to perform the Ajax update.
I would be interested to see what others have done or to hear if there are issues with the approach I have taken.
Set up a WindowClose callback.
In the WicketStuff project called ModelX (Disclaimer: I'm the developer of that) I have created an IWindowClosedListener interface which has a method:
void windowClosed(Panel panel, AjaxRequestTarget target)
So then any Page or Panel that can open a modal that needs to do something when that modal is closed simply implements that interface and its windowClosed method gets called at the right time.

Resources