0

I have form in my page, I am using ajax.beginform(). Inside this form I have submit button. On submit of input button I want action of form. Following is the piece of code which may be useful for you to understand.

 @using (Ajax.BeginForm("FormContainer", "Form",  new AjaxOptions { UpdateTargetId =      "HeaderMain", HttpMethod = "Post", InsertionMode = InsertionMode.Replace }))
        {
 <input name="" type="submit" value="Request" class="propel-viewDetailsButton" />

}

On click of input button I want to call java scrip t function where I want action of a form

tereško
  • 58,060
  • 25
  • 98
  • 150
suma
  • 119
  • 1
  • 3
  • 9

1 Answers1

0
$(".propel-viewDetailsButton").click(function() {
    var action = this.closest("form").prop("action");
}

Should do it :)

Spikeh
  • 3,540
  • 4
  • 24
  • 49
  • 1
    It would even be better if the form had an "id". – steveoh Mar 21 '12 at 07:58
  • Indeed - it would also be better if the button had an ID as well, so it could be targeted directly, as using a class selector could mean another element on the same page (with the same class) would also be selected. But he didn't ask us to give him best practices :) – Spikeh Mar 21 '12 at 08:05
  • Oh, you are right. :D But nice of us to discuss this here so that he can see it :) – steveoh Mar 21 '12 at 08:17