fifamaniac04
fifamaniac04

Reputation: 2383

Jquery with HttpPost in MVC 3

I have the following in my *.aspx page

$("#dialog-confirm").dialog({
            autoOpen: false,
            resizable: false,
            height: 418,
            width: 402,
            modal: true,
            buttons: {
                "Confirm": function () {
                    $('form').submit();
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });

This calls not only the Controller's Actionresult, but it calls a separate controller's ActionResult that is also found in the form. I don't want all the ActionResults found in the page to be invoked.

Q: How can I get my confirm button, found in the View for Members, to only call

//found in MemberController.cs
// POST: /Member/Create
 [Authorize]
 [HttpPost]
 public ActionResult Create(...){}

Upvotes: 0

Views: 36

Answers (1)

teo van kot
teo van kot

Reputation: 12491

If you want to submit only form that is inside dialog you could write like this, i think:

$("#dialog-confirm").dialog({
            autoOpen: false,
            resizable: false,
            height: 418,
            width: 402,
            modal: true,
            buttons: {
                "Confirm": function () {
                    //notice this part
                    $('#dialog-confirm form').submit();
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });

Upvotes: 1

Related Questions