views:

595

answers:

2

I'm using ajaxSubmit plugin to send Ajax forms, but for some reason this plugin doesn't send names/values of input[type=image]'s. So now I 'm catching submit event before ajaxSubmit will handle form and I'm guessing if it possible to find out what button was pressed?

+1  A: 
$("input .button-example").click(function(){
//do something with $(this) var
});

PS: do you have jQuery controling the $ var? Otherwise you have to do this:

jQuery.noConflict();
jQuery(document).ready(function(){
    jQuery("input .button-example").click(function(){
    //do something with jQuery(this) var
       alert(jQuery(this));
    });
});

if you wan't control on event (form submit)

$(document).ready(function(){
    $("#formid").submit(function() {
          alert('Handler for .submit() called.');
          return false;
    });
});

tell me something if it worked ;)

CuSS
I used something like that. I binded click to that other button and added hidden field to, so now server gets proper information...
newbie
+2  A: 

This will catch whichever input element initiated the submit:

$(document).ready(function() {
    var target = null;
    $('#form :input').focus(function() {
        target = this;
        alert(target);
    });
    $('#form').submit(function() {
        alert(target);
    });
});
karim79
Hi, thanx for suggestion, but it didn't work.
newbie