Is jquery.bind () deprecated?

Is jquery bind() deprecated or can it be used safely?

I see a lot of comments about bind () being deprecated in comments and responses via SO: JQuery Event: detecting changes in html / text div

Is there a JavaScript / jQuery DOM change listener?

and I don’t know whether it is safe to use or not (regardless of whether it is better or worse).

There is nothing deprecated in this: https://api.jquery.com/bind/

+5
source share
4 answers

I do not believe it is deprecated, but on is the preferred method of adding events.

http://api.jquery.com/bind/

Outdated means that they will delete it in the future, but their documents do not seem to talk about it.

EDIT:

Like jQuery 3.0 bind Deprecated. The above link is still relevant, but has since been updated. From your documents:

As with jQuery 3.0, .bind () is deprecated. It has been replaced by the .on () method to bind event handlers to a document with jQuery 1.7, so its use has already been discouraged.

+10
source

No, no, this is the difference between .on and .bind basically .bind is only called directly from the ie $("#elem").bind(...) element, so the element must exist by then the bind function is called. And .on can be attached to document i. e. $(document).on("click",".class",funcion(){...}); , therefore, if you add the item dynamically using .append or another way, the event will be valid.

+5
source

It is not deprecated in jQuery 1.1. Actually there is no difference (other than the use form) in jquery version 1.11.3 , if you check the .bind event declaration, which you can see, it just calls .on :

 bind: function( types, data, fn ) { return this.on( types, null, data, fn ); }, 

is outdated or can it be used safely?

According to others, no, it is not outdated and safe, it is now a little redundant and exists only for backward compatibility.

Although it seems to have been marked as deprecated in later versions of jquery now

+3
source

.bind() and .delegate() are deprecated from jQuery 1.12 and 2.2. These functions work well without warning in 1.12 or 2.2, but will not work in the next version and (of course) in 3.0.

Using .on() instead of .bind() and .delegate() strongly recommended.

http://blog.jquery.com/2016/01/08/jquery-2-2-and-1-12-released/ https://github.com/jquery/jquery/issues/2288

+3
source

Source: https://habr.com/ru/post/1235713/


All Articles