Javascript / JQuery: refresh tab in parent
I have a (parent) window containing JQuery tabs:
<div id="tabs">
<ul class="tabHeader">
<li><a href="?ctrl=doSomething" title="#tabs-something">
Awesome function</a></li>
<li><a href="?ctrl=showSettings" title="#tabs-showSettings">
Settings</a></li>
</ul>
</div>
Inside # tabs-showSettings, I require in some cases a new window that I open using the following code:
window.open('?control=showSetting&server='+server,
'serverSettings','width=400');
This works great. But in this window, I need a function to send the inputted data (works correctly), update the div inside the parent (doesn't work) and close the child window (works). This is what I tried:
// #1: the following would refresh the div within the child ;(
parent.$('div#tabs-showSettings').load('?control=showSettings');
// #2: the following doesn't seem to have any effect
window.opener.$('div#tabs-showSettings').load('?control=showSettings');
Please tell me what I am doing wrong. Thank you so much!
Decision:
$("div#tabs-showSettings", window.opener.document).load(
"?control=showSettings", function(){
window.close();
});
+2
source to share
1 answer
Try the parent context:
$("div#tables-showSettings", window.opener.document)
.load("?control=showSettings");
Update:
Some comments indicate to close the window after the updates are complete - this should be handled in a callback:
$("div#tables-showSettings", window.opener.document)
.load("?control=showSettings", function() { window.close(); });
+1
source to share