My problem: after loading an element through ajax, I bind some click function, but when the user loads the same element several times, the bound action will be repeated (do not replace, at least it looks like). I tried unbind, or click(function(){return false;});, but to complete the removal of the clic action from the element ...). What is the standard solution to this problem?
unbind
click(function(){return false;});
For most events, you can use live()(jQuery 1.3 +):
live()
$("td").live("click", function() { // do stuff });
This will associate the click event with the elements <td>that appear after this code is run.
<td>
, / , , .
jQuery 1.3.2, $('').live('click', function() {});, , , . .
$('').live('click', function() {});
Source: https://habr.com/ru/post/1720703/More articles:ΡΠ΅ΠΊΠΎΠΌΠ΅Π½Π΄Π°ΡΠΈΡ ΠΈΠ»ΠΈ ΠΎΡΡΠ°ΡΠ»Π΅Π²ΠΎΠΉ ΡΡΠ°Π½Π΄Π°ΡΡ Π΄Π»Ρ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠΈΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ "ΡΠ°ΠΉΠΌ-Π°ΡΡΠ°" Π΄Π»Ρ Π²Π΅Π±-ΡΡΡΠ°Π½ΠΈΡ Π΄Π»Ρ ΠΏΡΠ΅Π΄ΠΏΡΠΈΡΡΠΈΠΉ ΡΠ»Π΅ΠΊΡΡΠΎΠ½Π½ΠΎΠΉ ΠΊΠΎΠΌΠΌΠ΅ΡΡΠΈΠΈ Ρ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠ΅ΠΉ ΠΎ Π»ΠΈΡΠ½ΠΎΠΉ ΠΈΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΈΠΈ? - securitySql reporting services - programmatically configure a data source? - c #jQuery Clicking / changing an event does not work properly in IE7 / 8 - javascriptHow to list all computers and the last time they entered AD? - c #Using a user control from another project - c #Can you put an ASP.NET TODO preprocessor or tag in aspx source JavaScript? - javascriptGIT ΡΠ°Π±ΠΎΡΠΈΠΉ ΠΏΡΠΎΡΠ΅ΡΡ Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΠΌΠΈ ΡΠ°Π±ΠΎΡΠΈΠΌΠΈ ΡΡΠ°Π½ΡΠΈΡΠΌΠΈ ΠΈ ΡΠ΅Π½ΡΡΠ°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π½ΡΠΌ ΡΠ΅ΡΠ²Π΅ΡΠΎΠΌ - gitFirefox code (Gecko) - cache request - how do I get a list of devices? - firefoxwcf Removing wsdl from WCF Service with Flattened WSDL - wsdlIs there any use for porting the Haskell Edison and Core APIs to F #? - immutabilityAll Articles