Home  >  Article  >  Web Front-end  >  Solution to the problem of repeated triggering of JS events caused by Ajax partial update

Solution to the problem of repeated triggering of JS events caused by Ajax partial update

PHPz
PHPzOriginal
2016-05-16 16:34:041171browse

If the page contains an ajax updated list, then you need to be careful about event handling in the non-dynamic update part.

Take the list interface with a public toolbar as an example:

Solution to the problem of repeated triggering of JS events caused by Ajax partial update

$.ajax( 
.... 
data: { ... 
}, 
success: function(data) { 
$('Menu1').click( 
function(){ 
//do something 
} 
); 
} 
)

Since the Menu1 interface part is public, It will not be reloaded as the list data is updated, so the above code will generate repeated click event triggers (after updating the list multiple times).

So we have to note that the reinitialization of toolbar event listening cannot be included in the result processing of ajax list update.

Summary: The above is the entire content of this article, I hope it will be helpful to everyone’s study. For more related tutorials, please visit JavaScript Video Tutorial, AJAX Video Tutorial!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn