Home / Elements Quickstart Guide
Thank you for your interest of the Elements AJAX Web Framework. Now if you have already downloaded the latest Elements version, this quick start guide will tell you how to set it up for immediate use.
To run properly Elements requires PHP 5 enabled web server, and modern browser that supports Javascript. Elements will not run with Javascript disabled!
To install, simply extract the files from the distribution archive into a folder in your web server root directory.
The framework contain directories for specific purposes, explained as follow:
Now you're ready to create your first application. For starters, let's open the index.php file on the /app/gui directory using your favorite text or PHP editor, you will find this code:
<p>This is the index GUI!</p>
<form>
<component class="button" name="cmdhello">
<text value="Click Me!" />
</component>
</form>
Any PHP files inside the /app/gui directory defines a GUI page. You can use regular HTML to layout your interface. However, on Elements, there is the \<component> tag to define component as part of the layout. Let's try to add a text component:
<p>This is the index GUI!</p>
<form>
<component class="text" name="txthello">
<placeholder value="Type in something..." />
</component>
<component class="button" name="cmdhello">
<text value="Click Me!" />
</component>
</form>
Each component must have a class and a name, class defines what type of component it is, and name is to identify a component on a page. The code above will render as follow:

As you can see, each component also may have a design properties, for example, the text component have the placeholder design property.
Now open the index.js file on the same directory of the index.php file. A Javascript file having the same name with the GUI file will act as an event handler for the corresponding GUI. You will find this code inside the index.js file:
var elementseventhandler = function() {
return {
"page_title": "Home",
"cmdhello_click": function(evt) {
alert('Hello world!');
}
}
}
On the example above, when a click event occurs on the button component cmdhello, a 'Hello world!' message will be displayed on the screen. All event handler is written in the Javascript languange. Now let's add some more logic to the event handler:
var elementseventhandler = function() {
return {
"page_title": "Home",
"cmdhello_click": function(evt) {
var data = $page.components.txthello.text();
if (data.length == 0) {
alert('You type nothing!');
} else {
alert('Hello world! You type: ' + data);
}
}
}
}
Now, when a user clicks on the cmdhello button, the data typed on the txthello textbox is retrieved and validated, lastly a message is displayed on screen:

Each component have its own specific set of events, and by using event handler you can program logic into your application. Elements have many built-in objects that makes it easy to interact between components, calling services, accessing databases, and many more.
Now that you have completed your first application, you can explore more about Elements capabilities through this wiki, please go back to the wiki home to jump to specific section of documentation.