|
Project Information
Featured
Downloads
|
Watajax - A fast ajax jquery plug-in and a PHP data generator.Wa(West Art) Ta(Table) Jax(Ajax)This plug-in / php-data-generator combination was created when we could not find any easy-to-implement fast and non-complex alternatives. We are searching for developers who wish to help out in the future development. Please contact us if you are interested: christoffer@westart.se. Features
ExamplephpThere are two basic ways of using the included PHP data generator depending on what kind of data you want to show in your table. One for regular PHP generated arrays and one for MySQL table data. This example will show the MySQL one.
<?php
// Connect to the database first if you plan on using the Sql version of Watajax.
require_once("lib/Watajax.class.php");
$Watajax = new WatajaxSql();
$Watajax->columns = array(
"id" => array("name" => "#", "sort_type" => "numeric", "hide" => true),
"firstname" => array("name" => "First name", "transform" => '<img src="'.URI.'/images/icons/vcard.png" valign="absmiddle" /> !firstname'),
"lastname" => array("name" => "Last name"),
"email" => array("name" => "E-mail adress", "transform" => '<a href="show_reciptient.php?id=!id">!email</a>'),
"tools" => array("name" => "", "virtual" => true, "transform" => '<a href="edit.php?id=!id">edit</a>'));
$Watajax->run();
?>HTML/javascriptLoad jquery and the watajax plugin <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript" src="jquery.watajax.js"></script> Create a div/container for your to-be table in the <body> section of the page <div id="watajax_table"></div> Initialize the table. You have several options available. The most important ones to take notice of is ajax_connector that must point to your php-file (or other data source), and table_id that will deside what table to get data from. Those will be described later. You can always see them in the top of jquery.watajax.js file. <script type="text/javascript">
$(document).ready(function() {
$("#watajax_table").watajax({ajax_connector:"ajax.php", table_id: "contacts"});
})
</script>
|