views:

386

answers:

2

I have a bit of a situation I am currently using Jquery SimpleModal to do various dialogs on my site like for instance the logon dialog.

I'm also doing an Ajax.BeginForm helper.

Now everything works great and all but, what I need to know is what do I need to do to say close the modal when the user was sucessful at logging in..

I tried a few things like setting a tempdata value etc.. and then checking for that to close the modal via jquery or simply doing a windows.location to do a redirect... which then the modal would go away.

If I simply do a redirectoAction it populates the redirected action contents inside the modal in this case is whatever url they are returning from.

Thanks for the help.. much abliged.

Update: I got it so it closes the modal when sucessful, however what I am having an issue with now is when a user either just hits submit without entering anything the client side validation isn't working and the the user is redirected to the view that makes up that modal but without the modal.. so basically it is just the view without the rest of the site.

Any ideas on how to keep them at that modal until the proper information is entered?

+1  A: 

cant you just close it manually?

assume your modal is within an iframe, do

$('#modal',top.document).remove()
Funky Dude
+1  A: 

I agree with the earlier comment that it would be simpler to use Jquery throughout.

I believe that the best way to achieve what you are after would be to hook in a close dialog function to the OnSuccess of the AjaxForm.

<% using(Ajax.BeginForm("UpdateForm", 
         new AjaxOptions{OnSuccess="CloseModal()"})) { %>

To close simple modal you can call

function CloseModal() { $.modal.close(); }

Hope this helps.

madcapnmckay