最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to refresh a particular div after closing a modal window? - Stack Overflow

programmeradmin2浏览0评论

I have a modal window which closes when i add an item. The parent page will refresh once the modal window is closed. But i don't want the whole window to get closed, but i want a particular div to get refreshed. is there any javascript way to do it ?

I have a modal window which closes when i add an item. The parent page will refresh once the modal window is closed. But i don't want the whole window to get closed, but i want a particular div to get refreshed. is there any javascript way to do it ?

Share Improve this question asked Nov 22, 2011 at 7:07 BalaBala 3,62810 gold badges47 silver badges75 bronze badges 2
  • 1 its an ordinary jquery plugin with show_modal() – Bala Commented Nov 22, 2011 at 7:20
  • could u name it so i can post plete answer ! – Synxmax Commented Nov 22, 2011 at 7:54
Add a ment  | 

3 Answers 3

Reset to default 2

You can call a javascript method in the parent window while closing the child window. This is very simple.

You can have a javascript method to refresh the content of the div

<script language=”javascript” type=”text/javascript”>
function ParentWindowFunction()
{
    alert(‘Need to refresh targetdiv. I am instructed from child window’);
    //refresh the div
    return false;
}
</script>

And in the child window, you may have some button to close that window and also can call up the parent window's javascript

<script language=”javascript” type=”text/javascript”>
function CallParentWindowFunction()
{
    window.opener.ParentWindowFunction();
    return false;
}
</script>

<input type=”button”  name=”btn1″ value=”Call Parent Window Function” onclick=”javascript:return CallParentWindowFunction();”/>

Look after onClosed or Something like that method in your modal documentation , Look into below link , if you using one of jquery plugins for modal it's cleaner to use jquery load() method by searching for Jquery Ajax Update Div

http://api.jquery./load/

http://www.dynamicdrive./dynamicindex17/ajaxcontent.htm

I got a solution for this..firstly i would like to thank everyone above for giving their thoughts.

I just called the onload function of the div with the closemodal function which is being called while closing the modal window. it worked.

The modal window closes as per the ajax response. Onsuccess i called the onload function in the parent form. I will update with the code shortly.!

发布评论

评论列表(0)

  1. 暂无评论