ptamzz
ptamzz

Reputation: 9375

how to use jquery .live()

I've an input element with id newline. I'm using $('#newline').elastic(); to make it elastic using a jquery plugin. The input#newline can also be appended through an ajax call in which case the code $('#newline').elastic(); doesn't work and I've to use something like .live() to make it addressable in future also.

So can anyone help me how to implement .live() in this case??

Upvotes: 0

Views: 203

Answers (2)

ThiefMaster
ThiefMaster

Reputation: 318808

You will need to check the plugin's documentation if it has a setting to make it use live events instead of regular events. If not you could probably easily hack it to use live events instead of regular events or send a feature request to the developer.

Upvotes: 0

Quincy
Quincy

Reputation: 4433

Just call $('#newline').elastic(); after your ajax call. If you insist to use live(), you need to create a custom event after the ajax call by

$(this).trigger("newlineAddedEvent");

So you can check the event using live

$(":input").live("newlineAddedEvent",function(){$(this).elastic();});

Upvotes: 4

Related Questions