modal window + update
-
- Joomla! Apprentice
- Posts: 27
- Joined: Thu Nov 13, 2008 11:23 am
modal window + update
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
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
- dam-man
- Joomla! Exemplar
- Posts: 7961
- Joined: Fri Sep 09, 2005 2:13 pm
- Location: The Netherlands
- Contact:
Re: modal window + update
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
Dutch Boards | Joomla Coding Boards | English Support Boards
- nailson_imgn
- Joomla! Guru
- Posts: 729
- Joined: Wed Apr 15, 2009 5:33 pm
- Location: Fortaleza, CE - Brasil
Re: modal window + update
Trigger this js when you submit your modal window form. This shall reload the whole main page.
I don't tested myself, but it should be easy to adapt the code, if it don't work for what you want.
Code: Select all
window.parent.location.reload();
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------
-
- Joomla! Apprentice
- Posts: 27
- Joined: Thu Nov 13, 2008 11:23 am
Re: modal window + update
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
<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
- nailson_imgn
- Joomla! Guru
- Posts: 729
- Joined: Wed Apr 15, 2009 5:33 pm
- Location: Fortaleza, CE - Brasil
Re: modal window + update
Try
Code: Select all
window.parent.parent.location.reload();
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------
-
- Joomla! Apprentice
- Posts: 27
- Joined: Thu Nov 13, 2008 11:23 am
Re: modal window + update
no way !!
- nailson_imgn
- Joomla! Guru
- Posts: 729
- Joined: Wed Apr 15, 2009 5:33 pm
- Location: Fortaleza, CE - Brasil
Re: modal window + update
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!
-----------------------------------------------------------------------------------------
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------
-
- Joomla! Apprentice
- Posts: 27
- Joined: Thu Nov 13, 2008 11:23 am
Re: modal window + update
It is strange, but it doesn't work for me !!
do you place it at the onClick or onSubmit on the submit button??
do you place it at the onClick or onSubmit on the submit button??
- dam-man
- Joomla! Exemplar
- Posts: 7961
- Joined: Fri Sep 09, 2005 2:13 pm
- Location: The Netherlands
- Contact:
Re: modal window + update
Make sure you have also javascript tags around it.
Looks like you're writing javascript in PHP, that will not work
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
Dutch Boards | Joomla Coding Boards | English Support Boards
-
- Joomla! Apprentice
- Posts: 27
- Joined: Thu Nov 13, 2008 11:23 am
Re: modal window + update
Could you pass me some code to see how is it implemented ?
- nailson_imgn
- Joomla! Guru
- Posts: 729
- Joined: Wed Apr 15, 2009 5:33 pm
- Location: Fortaleza, CE - Brasil
Re: modal window + update
You can have this set at your main screen:
And then, in your modal window you do like this:
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...
Code: Select all
<script type="text/javascript" >
function timedReload( time ){ setTimeout( "window.location.reload()", time ); }
</script>
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>
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------