Skip to content

A jQuery plugin that automatically applies jQuery methods to elements that are dynamically added to the page

Notifications You must be signed in to change notification settings

adamlogic/jquery-always

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jquery-always

What is it?

A jQuery plugin that automatically applies jQuery methods to elements that are dynamically added to the page.

Methods

always()

All subsequent method calls in the chain (such as ‘click’, ‘addClass’, or any other jQuery method, built-in or custom) get applied both immediately and whenever new content is added dynamically.

How do I use it?

Let’s say you have a click handler defined like this:

$('.do_something').click(function() { alert('something') });

If you want to make sure that elements added dynamically also receive the ‘click’ method, use always():

$('.do_something').always().click(function() { alert('something') });

Any content added to the page will handled automatically:

$('body').append('<a href="#" class="do_something">click me</a>');

requires jQuery 1.3

Isn’t this the same as livequery?

It’s very similar but with fewer features and a modified API. I certainly got a lot of inspiration from livequery. My goal with this is to meet the same need that livequery met for me with a more simplified API and without the features I didn’t need.

About

A jQuery plugin that automatically applies jQuery methods to elements that are dynamically added to the page

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published