Live regions
{live} makes part of a page interactive without JavaScript of your own. A click on an element with pad-click inside the region posts the event to the page; the page runs again on the server, and only the region comes back and is swapped in.
|
PHP fragments/live_1.php |
HTML fragments/live_1.pad |
Result |
|---|---|---|
|
|
Clicked 0 times |
-
pad-click="add"on any element,pad-submit="save"on a form (its fields come along as ordinary request values),pad-change="pick"on a field (its name and value come along);pad-valueadds a value to the event. - The page's PHP reads the event with
padLiveEvent()and its value withpadLiveValue(); both are empty on an ordinary request. - State lives where a page keeps it: in the value the event carries, as here, in the session (
$padSessionVars), or in a database. - The region is a
<div data-pad-live="name">; the first region of a page brings the small script that does the posting and swapping.