jquery.unobtrusive-ajax bug?
===

I came across an issue when converting a normal post request using `Html.BeginForm` to an AJAX request using `Ajax.BeginForm` in ASP.NET MVC3.

The form in question has 2 submit buttons and code on the server would perform different actions depending on which submit button was clicked.

After turning it into an AJAX form all the data was posted as before <i>except</i> the name/value of the submit button that was clicked.

I had a look in the `jquery.unobtrusive-ajax.js` file to see if it should send the name/value of the button that was clicked and found this code that attaches these values as an attribute to the form which is later passed along in the post request.

    $("form[data-ajax=true] :submit").live("click", function (evt) {
        var name = evt.target.name,
            form = $(evt.target).parents("form")[0];

        $(form).data(data_click, name ? [{ name: name, value: evt.target.value }] : []);

        setTimeout(function () {
            $(form).removeData(data_click);
        }, 0);
    });

This is where my problem lies, the values of `evt.target.name` and `evt.target.value` were not the name and value of my submit button.

The HTML of my submit button is below. After a bit of investigation I found out that it was trying to read the name/value from one of the span's depending which part of the button I clicked. The [jQuery documentation for event.target][1] confirms this is expected behaviour. 

    <button class="t-button t-button-icontext" id="RAGRatingSaveButton" name="action" type="submit" value="Save">
        <span class="t-icon t-insert"></span>
        <span class="buttonText">Save</span>
    </button>

Now I believe I have fixed the "bug" by replacing evt.target with evt.currentTarget as per the code below. The [jQuery documentation for event.currentTarget][2] to me suggests that this is the correct way to go.


    $("form[data-ajax=true] :submit").live("click", function (evt) {
        var name = evt.currentTarget.name,
            form = $(evt.target).parents("form")[0];

        $(form).data(data_click, name ? [{ name: name, value: evt.currentTarget.value }] : []);

        setTimeout(function () {
            $(form).removeData(data_click);
        }, 0);
    });

I always feel a bit uneasy when edited a 3rd party file as I may be introducing other issues that I am not aware of. Also if another developer updates this file with a new version, my manually changes will be overwritten.

So, to the questions!

 1. `event.currentTarget` works for the 2 AJAX forms I have at the moment, is there any situations where `event.currentTarget` won't work?
 2. What are your thoughts on editing a 3rd party file? Would you do it?
 3. Do you think it is a bug? If so, what's the best way to report it to Microsoft? I've read many different ways (CodePlex, contact Phil Haack, post on ASP.NET forums)

Thanks in advance


  [1]: http://api.jquery.com/event.target/
  [2]: http://api.jquery.com/event.currentTarget/
  [3]: http://stackoverflow.com/questions/1417804/what-is-the-best-place-to-report-bugs-in-asp-net-mvc