Smutty
MVC Framework
Simple Ajax Links
You may already be familiar with the {link} function for creating links in your application. This is the exact same function you'll use for creating Ajax enabled links, so no re-learning required.
Updating an element
The simplest way to use ajax links is to make the link update an element
on the page. You do this by specifing the id of the element to update with
the update attribute. The link below is to an action which
just prints out the current date and time.
# template code
{link
update="myDiv"
url={ controller="demo" action="theDate" }
text="Show Me The Date"
}
# demo controller
function theDateAction() {
echo date( 'Y/m/d H:i:s' );
}
CLICK ME: Show Me The Date
MyDiv (no date until you click the link above)
If you keep clicking the link you'll see that the second are incrementing. How easy was that!