Multiple buttons on "form"ized table.

Multiple buttons on "form"ized table.

dneedlesdneedles Posts: 24Questions: 0Answers: 0
edited February 2010 in General
I was mucking with the "Submit form with elements in a table" example. I was able to add a second button but am unclear how to distinguish them apart via:
[code]$('#form').submit( function()...)[/code] Is there a quick example someone can point me to?

Replies

  • dneedlesdneedles Posts: 24Questions: 0Answers: 0
    edited February 2010
    I found the discussion of the "submit" function which is a simplification of .bind -> http://api.jquery.com/bind/
    Still trying to figure out a solution. The problem is that the tag #form in the example is tied to the form, thus if you click any button it will trigger the same code. However, when I moved the ID to the button, nothing happened via:
    [code] $(document).ready(function() {
    $('#edit2').bind('submit', function() {
    var sData = $('input', oTable.fnGetNodes()).serialize();
    alert( "The following data XXX have been submitted to the server: \n\n"+sData );
    return false;
    } );
    $('#delete2').bind('submit', function() {
    var sData = $('input', oTable.fnGetNodes()).serialize();
    alert( "The following data would have been submitted to the server: \n\n"+sData );
    return false;
    } );
    [/code]

    and
    [code]

    Edit Selected
    Delete Selected

    [/code]
    Any idea on how to have two buttons on the same table? Or at least distinguish the buttons within the function called?
  • dneedlesdneedles Posts: 24Questions: 0Answers: 0
    I found only a work around to the problem by using a form in conjunction with the list. I do not see a way to have more than 1 button associated with the table.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The submit function is given an event object by jQuery - so you can use that to find out which node was clicked on (e.targetNode for example): http://api.jquery.com/submit/

    Allan
This discussion has been closed.