Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

You can refresh the page using a ajax call

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

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

})

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top