live

jquery .live('click') vs .click()

浪尽此生 提交于 2019-11-26 06:18:54
问题 I am wondering whether there are any circumstances where it would be better to use .click(function {...}); rather than .live(\'click\', function {...}); ? From what I gather the live option seems to be a better option and I am hence using it in almost all circumstances instead of the plain .click(), especially given a lot of my code is loaded asynchronously. EDIT: Another part to this question. If I\'m asynchoronously loading all the javascript in, .click will still pickup all elements

jquery click doesn't work on ajax generated content

落花浮王杯 提交于 2019-11-26 03:35:22
问题 I am using $(\".button\").on(\"click\", function(){ }); to click to a button which is on a container but then an ajax call is done and the content gets updated with new stuff and then when i try to click .button it wont work... nothing will get returned when i click the button. I even tried $(\".button\").live(\"click\", function(){ }); or $(\".button\").click(function(){ }); How can I make it work? EDIT : my html: <div class=\"container\"> <ul> <li>item1</li> <li>item2</li> <li>item3</li> <

.live() vs .bind() [duplicate]

一个人想着一个人 提交于 2019-11-26 03:08:42
问题 This question already has an answer here: What is the difference between the bind and live methods in jQuery? 10 answers I want to know the main difference between .live() vs. .bind() methods in jQuery. 回答1: The main difference is that live will work also for the elements that will be created after the page has been loaded (i.e. by your javascript code), while bind will only bind event handlers for currently existing items. // BIND example $('div').bind('mouseover', doSomething); // this new

jQuery: live() vs delegate()

假如想象 提交于 2019-11-26 00:48:01
问题 I\'m using jQuery in my web application. While reading its documentation I read about live() and delegate() . Although they have explained both methods, I don\'t understand the exact difference between them. Also not sure about which method is ideal in which scenario. Please help me to get clear understanding of these methods. Thanks 回答1: .live() requires you run the selector immediately, unless you're using the result it's very wasteful. The event handler here is attached to document , so

Jquery live() vs delegate() [duplicate]

霸气de小男生 提交于 2019-11-26 00:13:06
问题 This question already has an answer here: jQuery: live() vs delegate() 4 answers I\'ve read some posts here and elsewhere on the web about the differences between live() and delegate() . However I haven\'t found the answer I\'m looking for (if this is a dupe please tell me). I know that the difference between live and delegate is that live cannot be used in a chain. I also read somewhere that delegate is in some cases faster (better performance). My question is, is there a situation where you

jQuery 1.9 .live() is not a function

∥☆過路亽.° 提交于 2019-11-25 23:06:35
问题 I recently updated jQuery from 1.8 to 2.1. I suddenly discovered that the .live() stops working. I get the error TypeError: $(...).live is not a function . Is there any method I can use in place of .live() ? 回答1: jQuery .live() has been removed in version 1.9 onwards. That means if you are upgrading from version 1.8 and earlier, you will notice things breaking if you do not follow the migration guide below. You must not simply replace .live() with .on() ! Read before you start doing a search