Download the PHP package aygon/jatun without Composer
On this page you can find all versions of the php package aygon/jatun. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package jatun
Jatun Documentation
This library implements a low level communication interface between your (server-side) PHP project and your (client-side) jQuery application.
Installation
Follow these steps to install the library in your php project.
Add the following to your composer.json
file:
Update the vendor libraries:
Application - PHP
The Jatun environment validates and parses an array of events you want to send to the client using generic event classes. These events are encoded using an encoder (by default JSON encoder) and send to the client.
Building the Environment
The environment is the base object of the library. It handles all validation, parsing and encoding of the event array. Generic events can be added to this object to extend the support of events:
Default Events
The library already includes some basic events, in this section these events are explained:
Html
The html event adds the functionality to change the inner html of an html node based on its id.
Usage
Flash message
The flash message event adds the functionality pop up a flash message inside a html node based on its id.
Usage
Dialog open
The dialog open event adds the functionality to open a jQuery dialog with a given id, title and content
Usage
Dialog title
The dialog title event adds the functionality to change the title of a jQuery dialog based on its id.
Usage
Dialog close
The dialog close event adds the functionality to close a jQuery dialog based on its id.
Usage
Application - Javascript
At client side the JSON response from the server is parsed back to an array of events, which are fired sequentially, prefixed with "jatun."
In order to make the basic Jatun functionality work at client-side, jQuery, jQuery-UI and the Jatun library should be included:
In order to change click behavior on an element, or submit behavior of a form the following javascript can be used. If the selected element is not an a or form tag, Jatun tries to find a data-path attribute on the element:
Also a custom Jatun request can be done in the same way as a jQuery ajax request, but in this case the success handler does not have to be implemented:
Writing custom events
In order to create a custom event, a
Symfony Bundle
Jatun also comes with a built in Symfony Bundle for easy integration in your Symfony project. For the Symfony bundle documentation see bundle docs