modal window + update

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
amoreno
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Thu Nov 13, 2008 11:23 am

modal window + update

Postby amoreno » Thu Oct 29, 2009 3:51 pm

Hi,

I am developing a component and i got stuck on that.

I have a component with a table view, on this table view I have an link on every item to edit it.
I did it using amodal window, I am able to click on edit, the nice modal window opens, I modify the data (the data is well modified) and then i close the window.

But the parent window is not actualised (if i refresh the window, then the data appears actualised),
but it should be a way of doing it actomatically isn't??

Can anyone help me?

What i did to get the modal window is the followind:

1.- put JHTML::_( 'behavior.modal'); on view.html.php
2.- use on the table: <a class="modal" id="popup" rel="{handler: 'iframe', size: {x: 650, y: 700}}" href="?option=com_mycomponent&tmpl=component&id=<?php echo $item->id; ?>"><img src='./images/M_images/edit.png' alt='View details' border=0></a>

thanks in advance,
Albert

User avatar
dam-man
Joomla! Exemplar
Joomla! Exemplar
Posts: 7961
Joined: Fri Sep 09, 2005 2:13 pm
Location: The Netherlands
Contact:

Re: modal window + update

Postby dam-man » Thu Oct 29, 2009 7:36 pm

You need to do it with AJAX then. Otherwise you will not update the parent window. A modal box is AJAX but won't refrsh the parent window.
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards

User avatar
nailson_imgn
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Apr 15, 2009 5:33 pm
Location: Fortaleza, CE - Brasil

Re: modal window + update

Postby nailson_imgn » Thu Oct 29, 2009 9:09 pm

Trigger this js when you submit your modal window form. This shall reload the whole main page.

Code: Select all

window.parent.location.reload();


I don't tested myself, but it should be easy to adapt the code, if it don't work for what you want.
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------

amoreno
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Thu Nov 13, 2008 11:23 am

Re: modal window + update

Postby amoreno » Fri Oct 30, 2009 7:40 pm

Hi I tried to use it on the button
<button class="button validate" type="submit" class="validate" onClick="parent.window.location.reload()">
<?php echo JText::_('Save') ?>
</button>

and on the form by doing onSubmit, and both of them did not work !!

Where else could i place this reload to be effective?
Or what alternative could i apply?

NOTE: I also tried window.parent.location.reload().

Albert

User avatar
nailson_imgn
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Apr 15, 2009 5:33 pm
Location: Fortaleza, CE - Brasil

Re: modal window + update

Postby nailson_imgn » Tue Nov 03, 2009 11:38 am

Try

Code: Select all

window.parent.parent.location.reload();
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------

amoreno
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Thu Nov 13, 2008 11:23 am

Re: modal window + update

Postby amoreno » Tue Nov 03, 2009 12:04 pm

no way !!

User avatar
nailson_imgn
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Apr 15, 2009 5:33 pm
Location: Fortaleza, CE - Brasil

Re: modal window + update

Postby nailson_imgn » Tue Nov 03, 2009 12:13 pm

You're right. I just tested here and that doesn't work. However, I also tested window.parent.location.reload(); and it works fine for me, so it should work for you as well...
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------

amoreno
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Thu Nov 13, 2008 11:23 am

Re: modal window + update

Postby amoreno » Tue Nov 03, 2009 3:05 pm

It is strange, but it doesn't work for me !!

do you place it at the onClick or onSubmit on the submit button??

User avatar
dam-man
Joomla! Exemplar
Joomla! Exemplar
Posts: 7961
Joined: Fri Sep 09, 2005 2:13 pm
Location: The Netherlands
Contact:

Re: modal window + update

Postby dam-man » Tue Nov 03, 2009 3:05 pm

Make sure you have also javascript tags around it.
Looks like you're writing javascript in PHP, that will not work
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards

amoreno
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Thu Nov 13, 2008 11:23 am

Re: modal window + update

Postby amoreno » Tue Nov 03, 2009 3:16 pm

Could you pass me some code to see how is it implemented ????

User avatar
nailson_imgn
Joomla! Guru
Joomla! Guru
Posts: 726
Joined: Wed Apr 15, 2009 5:33 pm
Location: Fortaleza, CE - Brasil

Re: modal window + update

Postby nailson_imgn » Tue Nov 03, 2009 4:09 pm

You can have this set at your main screen:

Code: Select all

<script type="text/javascript" >
function timedReload( time ){ setTimeout( "window.location.reload()", time ); }
</script>


And then, in your modal window you do like this:

Code: Select all

<script type="text/javascript" >
function submitForm(){
var canSubmit = false;
// Validate some fields
if( canSubmit ){
    // Test with different delays, so you can be sure that your
    // form is submitted before tha main page gets reloaded
    window.parent.timedReload( 2000 );
    form.submit();
}
</script>


Note: if you don't manage to call the main window function like this, you can assign it to a hidden button and then fire its onclike event. Hope it helps...
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------


Return to “Joomla! 1.5 Coding”

Who is online

Users browsing this forum: No registered users and 4 guests