0

I'm currently writing an internal application that handles our company's billing using MVC 3.

One of the requirements that Finance has is that a user can access a particular Client's Properties (A one-to-many relationship) through a tab control on the page. When they want to edit or delete a property, they want the Edit/Delete screen to come up in a new tab or window.

If they decide to delete the property in the new tab/window, how can I refresh the first tab/window so that they can't select the recently deleted property?

EDIT: I forgot to mention that when they are finished editing/deleting the property the tab/window automatically closes.

Corey Adler
  • 15,897
  • 18
  • 66
  • 80
  • I wrote this little JS class to facilitate communication between tabs/windows, which might be helpful. You could easily set up a callback to refresh: https://github.com/jeremyharris/local_connection – jeremyharris Oct 04 '12 at 14:35
  • 2 of my older questions getting a -1 at the same time? I think someone is upset at me for something. Reveal yourself! – Corey Adler Apr 09 '13 at 14:23

3 Answers3

3

Time to answer my own question, based on this answer to a different question that discussed the beforeunload event.

So I hooked up the beforeunload event to do the refresh on the window's opener by doing the following script:

 $(window).bind("beforeunload", function () {
      window.opener.location.reload(true);
 })

Nice, clean, and simple.

Community
  • 1
  • 1
Corey Adler
  • 15,897
  • 18
  • 66
  • 80
0

You can refresh the page using a ajax call

$(document).ready(function(){
   setInterval(loading(),1000);

function loading(){
 $("#loaddiv").load("your url");
}

})
StaticVariable
  • 5,253
  • 4
  • 23
  • 45
0

If the dialog is a browser window you can refresh the parent (the window that opened the dialog) through:

window.parent

The solution is then a javascript function in the parent that refresh the list of elements:

function getClientProperties(int idClient) { ajax refresh on the list }

When an user edit or delete a property you just call in the modal the parent function getClientProperties() passing the idClient (or a property that reference the client) through:

window.parent.getClientProperties(idClient)

If the modal is a div inside the same page, opened through jquery for example, the solution is easier because you just refresh or control the elements as the user edit or delete properties.

jparaya
  • 1,331
  • 11
  • 15