Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery.submit is deprecated as of 3.3 what's the alternative?

Tags:

jquery

By checking the source you can see:

/**
 * Bind an event handler to the "submit" JavaScript event, or trigger that event on an element.
 *
 * @param handler A function to execute each time the event is triggered.
 * @see {@link https://api.jquery.com/submit/}
 * @since 1.0
 * @deprecated 3.3
 */

However it seems this isn't mentioned in the jQuery blog here. What is the alternative for this that it's now being marked deprecated?

like image 935
Renari Avatar asked Feb 28 '18 21:02

Renari


3 Answers

You can use .on

$(selector).on("submit", callback)

Read more about it at http://api.jquery.com/on/

like image 123
void Avatar answered Nov 18 '22 11:11

void


I was also searching for this but in my case I wanted to trigger submit. In that case you do it by triggering the event:

$(selector).trigger("submit")
like image 41
Charlie Araya Avatar answered Nov 18 '22 10:11

Charlie Araya


It isn't deprecated, you can check here the .submit() API docs:

https://api.jquery.com/submit/

like image 1
leopinzon Avatar answered Nov 18 '22 11:11

leopinzon