jquery: binding events is dynamically loaded elements

One problem in doing the project recently found by ajax dynamic loading out a button click event can not bind value. I am using datatables this form plugin, the form is dynamic content rendered through ajax.

solution:

By Google, I found that usually .live () This event before jquery1.7 version, but this method was removed in version 1.9

 

So, we need to find an alternative method .on (), let us first look at the introduction of this event

 

See the introduction, these two events do something similar, and then I found this in a specific presentation

 

The first point: .on () event binding element must be a page that already exists, that is, static html elements present, will be binding.

The second point: by proxy selector parameter, what does that mean? That is when this parameter is not empty when, .on () event will not be binding on the trigger element binding directly, it will automatically match an internal node, then the node is triggered

How to understand the second point of it? Popular point that: a father (already binding element static pages) tube with a lot of sons (dynamically loaded out of the elements), we first find his father, and told one of his son's name and wanted to do something ( event specific binding), then he will let you go to the designated son to get there. In this way it is easy to understand.

 

Here, the problem is solved. Specific wording like this:

 

The above is my entire process to solve the problem, hoping to help to you, and common progress! ! !

 

This article Reference document:

https://www.jquery123.com/

Guess you like

Origin www.cnblogs.com/lxlry/p/11236840.html