Skip to content

jblz/Ajax-Include-Pattern

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ajax-include pattern

Copyright 2012, Scott Jehl, Filament Group, Inc. Original idea from Scott Gonzalez :)

Dual licensed under MIT and GPLv2

How-to

To use, add attributes to elements in your page where non-essential fragments of content can be included from an external URL, using jQuery-api-like qualifiers like data-after, data-before, data-append, and data-replace:

Replace:

<a href="..." data-replace="articles/latest/fragment">Latest Articles</a>

Before:

<a href="..." data-before="articles/latest/fragment">Latest Articles</a>

After:

<a href="..." data-after="articles/latest/fragment">Latest Articles</a>

Append:

<a href="..." data-append="articles/latest/fragment">Latest Articles</a>

Also, the data-threshold attr allows a min width for this to apply.

Note: these attributes can be placed on any element, not just anchors.

Once the DOM is ready, you can apply the plugin like this:

$("[data-append],[data-replace],[data-after],[data-before]").ajaxInclude();

Optional Proxy

To use the proxy and include all ajax includes in one call, just pass in a URL that is ready to accept a list of files, such as the ajaxinclude.helper.php file in the root.

$("[data-append],[data-replace],[data-after],[data-before]").ajaxInclude( "ajaxinclude.helper.php?files=" );

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published