Welcome Guest, Not a member yet? Register   Sign In
[JS Help]refresh a div
#1

[eluser]minoh[/eluser]
Hi guys,

I have a popup wich stores data on session, i want to on submitting the form, refresh the table placed in a div on the parent page.

i just need to refresh the div.

thanks.
#2

[eluser]pistolPete[/eluser]
I'd use jquery.
Load jquery in both the popup and the parent window.
Then you need to catch the submit event in the popup window:
Code:
$("#popup_form").submit(function () {
    // invoke the div-refresh
    window.opener.$("#some_div").load('/some_controller/some_function');
});
#3

[eluser]minoh[/eluser]
Nothing change, still have no refresh, this is what i wrote:

Code:
//loading jquery in both popup and parent page

[removed]
$('#popupFournituresEdit').submit(function()
{
   window.opener.$('#fournituresDiv').load("<?php echo base_url(); >interventions/general/add");
});
[removed]
#4

[eluser]pistolPete[/eluser]
Did you check (using Firebug) if there any JS errors?
#5

[eluser]minoh[/eluser]
[quote author="pistolPete" date="1256307232"]Did you check (using Firebug) if there any JS errors?[/quote]
I get a : Failed to load source for : http://localhost/.../add
do you have an idea, what can be the problem ?
#6

[eluser]minoh[/eluser]
[quote author="minoh" date="1256308025"][quote author="pistolPete" date="1256307232"]Did you check (using Firebug) if there any JS errors?[/quote]
I get a : Failed to load source for : http://localhost/.../add
do you have an idea, what can be the problem ?[/quote]
i fixed the error, it was because i include prototype.js which i dont use.
now i have no error but still have no refresh of the parent page div.
#7

[eluser]minoh[/eluser]
i modify the script to :

Code:
if(document.popupFournituresEdit.submit)
{
   window.opener.$('#fournituresDiv').load('../General/add');
}

the refresh action works, but the entire page is duplicated on the Div.

any help ?
#8

[eluser]pistolPete[/eluser]
The function which you load using $('#fournituresDiv').load(...) should just return the contents of the div, not the whole page!
#9

[eluser]minoh[/eluser]
[quote author="pistolPete" date="1256332023"]The function which you load using $('#fournituresDiv').load(...) should just return the contents of the div, not the whole page![/quote]
but if the function should just return the contents of the div, that means that i have to create function for every table display ? and also where the parent 'url' should be entered if the load will contains the 'div contents method' ?
#10

[eluser]pistolPete[/eluser]
[quote author="minoh" date="1256336850"]but if the function should just return the contents of the div, that means that i have to create function for every table display ?[/quote]
How much do the tables differ? Maybe you could use one function for all, but that depends on your content. Please post some example data and use cases.

[quote author="minoh" date="1256336850"]and also where the parent 'url' should be entered if the load will contains the 'div contents method' ?[/quote]
I don't understand your problem there, could you explain it again?




Theme © iAndrew 2016 - Forum software by © MyBB