0

I've got a Bootstrap modal window that has an ActionLink to call a method in the controller and to do stuff:

@Html.ActionLink("Process Data", "ProcessData", "Controller", null, new { @class = "btn btn-success" })

However, I want to do it so that when the user presses this ActionLink (the Save Changes button), I want the modal to close automatically after they press it.

Is there a way to directly call another jQuery/Javascript method once ProcessData finishes executing? This also isn't a POST method if it matters.

3
  • You may write Js function onclick event to close the model. How are you calling controller method? ajax? Commented Sep 27, 2017 at 18:45
  • It sounds like maybe the call to ProcessData should be called in an Ajax call rather than an Actionlink. Commented Sep 27, 2017 at 18:46
  • Possible duplicate of stackoverflow.com/questions/2856071/… Commented Sep 27, 2017 at 19:02

1 Answer 1

0

I think the code below executes the someFunction function before the Controller/Action

@Html.ActionLink("linky", "action", "controller", new { onclick = "someFunction();"})

So if you want to control the flow you can use ajax, declare the button

<input type="button" id="btnAction" />

Then assign an action to your click event

$('#btnAction').click(someFunction);

And now implement your function using ajax

$.ajax({
            url: url/controller/action',
            type: 'GET',
            headers: headers,
            success: function (data) {
                //HERE YOUR CODE IN YOUR CONTROLLER WAS EXECUTED/FINISHED AND 
                //YOU CAN CALL YOUR JS FUNCTION

                yourSECONDfunction();
            }
        });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.