views:

2106

answers:

4

I want to close a Simplemodal window from a JavaScript function that gets called automatically after a form is submitted and the results recived (AJAX), using ASP.Net MVC. How do I close a jQuery Simplemodal?

I've opened it this way:

$("#popup").modal()
+1  A: 

Just call close.

$("#popup").close();

If you're doing it for an ajax completion you need to add a callback. You may want to check for failure.

var foo = $("#popup").modal();

$.ajax({url:url, success:function(){
    foo.close();
}});
gradbot
+8  A: 

You have 2 options:

1) Put the close class (simplemodal-close) on an element in your modal data and SimpleModal will automatically bind the close function to the click event on that element.

Taking the example above, you'd want:

<div id="foo" style="display:none">
  <p>Form HTML</p>
  <span class="simplemodal-close">Close</span>
</div>

2) When you want to close the dialog programatically, call:

$.modal.close();

HTH!

-Eric (SimpleModal author)

Eric Martin
A: 

Ive had a similar prob and tried class="simplemodal-close". My code is

    <div id='basic-modal'>
        <a href='#' class='basic'>Demo</a>
    </div>


    <div id="basic-modal-content">
        <iframe src="something.jsp" height="450" width="600"></iframe>
    </div>

I have a submit button in the something.jsp page. All work perfert. but unable to close the modal box when clicked on submit. i included

I need to know if i should inlude the .js sript in both the pages. I totally new to scripting. Can you tell me how exactly to close the modal on clicking the submit button.

Pooja
A: 

$.modal.close();

or you can use command setTimeout('goto_previous_page()', 1000);

dhaniBinZain