A
A
Andrey2019-02-08 08:56:43
JavaScript
Andrey, 2019-02-08 08:56:43

How to catch the pressed button on the .submit event?

I have a form with two buttons.

<form>
  <!-- поля формы -->
  <button type="submit"></button>
  <button type="submit" name="printing"></button>
</form>

The logic is so arranged that it namedoes not come to the server and it will not work to determine which button is pressed by it (on the server).
But in js there is processing of submitting the form to the server, so I want to put some logic there.
Inside the form
_this.submit (event) ->
        event.preventDefault()
        //.......
        // здесь отлавливаю кнопку, которая нажата и ее атрибуты
 $.post $(this).attr('action')
        , $(this).serialize() + printing
        , (data) ->
        //.......

How to determine which button is pressed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question