The UI components
The main change in the version 5 of Jaxon, which is also an innovation in the field, is the introduction of UI components.
A component is a PHP class that is attached to a DOM node in the HTML code.
It provides a html()
method which returns some HTML code, and a render()
method which, each time it is called, will replace the attached DOM node content with the value returned by the html()
method.
Combined to databags and to stash, which allow to share data between the browser and the server, and between different components in the application, this feature makes it possible to esily build complex UI in Ajax and PHP.
The templates
New templating features are added to attach the composants to DOM nodes, define events handlers, and also to insert the Javascript and CSS codes generated by the library into the web page.
In addition to the templates, the PHP and Javascript api of the request factory
, which generates calls to Javascript (or jQuery) functions and selectors and set them as events handlers to them, has been greatly improved.
Commands rewrite
The names and formats of the commands that are embedded in Response
objects have been changed.
The names and parameters of the commands are now more explicit (node.assign
instead of as
for example).
Obsolete commands have also been removed. These are the ones who allowed to dynamically include Javascript functions or Javascript and CSS files in the web page. Modern frontend tools provide better alternatives to these functions.
The Response
class
The Response
class does not store the commands anymore, and its instances now act as proxies to a command manager object.
As a consequence, the functions of the Jaxon classes do not need to return a Response
object anymore.
The syntax of the confirm()
function of the Response
class was also changed.
The configuration manager
A new package was created to implement the configuration options management, which are now stored in immutable objects.
Upload with iframe
This feature, which allowed Ajax upload in browsers that do not natively support the feature, was removed.
Using attributes in Jaxon classes (under development)
The jaxon-annotations package currently allows the implementation of some features in Jaxon classes using annotations, like @upload
.
The jaxon-attributes package provides the same features, but with attributes. However, it is still under active development.
Development in monorepo
The Jaxon library is now developed in a monorepo. The repositories of all the packages included in that monorepo are now only accessible for reading.
Javascript code rewrite
A major part of the Javascript library was rewritten, to adapt the multiple changes brought to the PHP library.
This includes in particular a new parser which interprets and executes the commands embedded in responses to Ajax requests, in their new json format.
The dialog plugins
The structure of the dialog plugins was simplified, and their code is now written in Javascript only. The PHP classes role is only to declare the plugin, and insert their Javascript and CSS codes in the web page.
Alternatives to jQuery
The Jaxon library currently makes use of certains jQuery
-specific functions, such as selectors or events handlers.
For those who don't want to use jQuery
, it is now possible to use a more lightweigth alternative instead.
Currently, the Chibi.js library is supported, and other libraries may be added in the future.