TH1981
TH1981

Reputation: 3193

using jQuery .live with .bind

okay, I understand the basics of jQuery, and I know that in some instances I've had to use .live('click',function(){...}); instead of .click(function(){...}); to get the method to fire correctly.

the method I'm currently looking at is: $('#title').bind('keyup', function(){...});

This works great, except because it's in a bit of code that isn't called until another action is preformed, I'd need to use .live() as described above.

Problem is, I don't know how to format this one to work using the .live() method instead of .bind() as shown above. Can someone please help?

Thanks in advance!

Upvotes: 0

Views: 162

Answers (3)

Sandwich
Sandwich

Reputation: 2289

Using live is the same as using bind, except that it is limited only to the events click, dblclick, keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover, and mouseup.

$('selector').live('event',fn);

Upvotes: 3

Dean Burge
Dean Burge

Reputation: 3461

@dskvr is correct - the usage syntax is the same. But you also might like to read up on the differences between live(), bind() and delegate().

Upvotes: 0

TH1981
TH1981

Reputation: 3193

odd, I thought I saw the answer up, but then it seemed to disappear before I could accept. At any rate, using the following worked:

$('#title').live('keyup', function(){...});

Upvotes: 0

Related Questions