My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Links

Scatter.js - a lightweight ajax library for element scattering

Copyright (c) 2010 Q42 Written by Martin Kool

Scatter sends a form (or retrieves a URL) through ajax. If the response contains elements (at top level) with ids that correspond with ids on the current page, the current element will be replaced. This is called "scattering" of elements.

Scatter is a 100% RESTful ajax library with only a 2k footprint, when compressed. It supports forms with multiple submit buttons, several ways of initialization and a clean API. The source code provides Visual Studio intellisense when used in VS.

Scatter works standalone but is fully compliant with jQuery, Mootools, Prototype or any other js library.

Usage:

1. You can specify a rel="scatter" attribute on a form or hyperlink. You only need to

run Scatter.scanPage() once, when the page is loaded. This can be done through
<body onload="Scatter.scanPage()">
, or any other way you prefer.

2. Another usage is through event handlers on the form element or link, as follows:

<form onsubmit="Scatter.send(event)">
or

3. Or, you could use the Scatter API directly:

Scatter.get("/my-url?foo=bar"); Scatter.post("/my-url", "?foo=bar"); Scatter.delete("/my-url", "?foo=bar"); Scatter.put("/my-url", "?foo=bar"); Scatter.submit(myForm);

All these API calls have an optional last parameter in which you can specify your own handler. Check the method documentation below for details.
Powered by Google Project Hosting