Reload parent window from Modal

603 views
Skip to first unread message

Jon Lackey @zuno

unread,
Aug 26, 2009, 11:33:17 PM8/26/09
to Joomla! General Development
Does anyone have a good idea on how to reload a parent window from a
modal?

I'm doing J! login from a modal and I want to reload the parent window
once the user is authenticated.

My thinking is to send the modal iframe to a page upon authentication
and use JavaScript to reload the parent window. That seems pretty
nasty though.

Thanks for any help!
-Jon

Luis Galárraga

unread,
Aug 27, 2009, 12:02:07 AM8/27/09
to joomla-de...@googlegroups.com
Hi Jon:

Fortunately I am working on that stuff right now:

            window.parent.document.location.reload(true);
            window.parent.document.getElementById('sbox-window').close();                   

The first line does the reload, the second one closes the modal. I hope this information can help you.

Cheers,
Luis

2009/8/26 Jon Lackey @zuno <webmo...@gmail.com>

Jon Lackey @zuno

unread,
Aug 27, 2009, 12:02:36 AM8/27/09
to Joomla! General Development
Here's what I have working, but it seems over-kill...

On successful login the modal iframe is loaded with index.php?
option=com_planner&view=redirect (com_planner is a custom component).
The only reason I have the view "redirect" is to reload the parent
window.

The redirect view.html.php file has this...

class PlannerViewRedirect extends JView {

function display($tpl = null) {

$doc = &JFactory::getDocument();
$js = 'window.parent.location.href = \''.JRoute::_('index.php?
Itemid=49').'\';';

$doc->addScriptDeclaration($js);

parent::display();

}

}

So when this is loaded the js in the head redirects the parent to the
specific page. This works, but I've got a whole new view just to
handle it. I'm sure I'm missing something obvious. Could I cut this
short and somehow handle it all in the controller?

Jon Lackey @zuno

unread,
Aug 27, 2009, 12:05:33 AM8/27/09
to Joomla! General Development
Thanks Luis.

The problem with that method (I assume you're doing this with the
button onclick???) is that if the user is not authenticated it still
reloads the page.

Also if you reload the parent window you don't need to close the modal
since it will be gone with the parent reload.

On Aug 26, 9:02 pm, Luis Galárraga <shamant...@gmail.com> wrote:
> Hi Jon:
>
> Fortunately I am working on that stuff right now:
>
>             window.parent.document.location.reload(true);
>             window.parent.document.getElementById('sbox-window').close();
>
> The first line does the reload, the second one closes the modal. I hope this
> information can help you.
>
> Cheers,
> Luis
>
> 2009/8/26 Jon Lackey @zuno <webmonk...@gmail.com>
Reply all
Reply to author
Forward
0 new messages