Andrew Plummer - Design Development Translation

Example 10: Adding HotText

Summary

One feature I was happy to add to TableGear was the ability to make it compatible with another script I have developed: HotText. I've created a shortcut option to make setting up TableGear with HotText easy.

Example

View Example

PHP Code

$tg = new TableGear(array( "database" => array( "username" => "USERNAME", "password" => "PASSWORD", "database" => "DATABASE", "table" => "TABLE" ), "sortable" => "all", "editable" => "all", "loading" => array( "tag" => "img", "attrib" => array( "src" => "/images/icons/loading.gif", "alt" => "Loading...", "class" => "loading" ) ), "formatting" => array( "price" => "currency[prefix=$,pad], "date" => "date" ), "totals" => array("price", 5), "hotText" => array("price", "quantity") );

HTML Code

<script type="text/javascript" src="MooToolsMore.js"></script> <script type="text/javascript" src="HotText.js"></script> <script type="text/javascript"> new HotText(".hotText"); </script>

Adding HotText is as easy as passing a name or number for the column you want it applied to in TableGear's PHP constructor, then passing hotText as the CSS selector in the Javascript constructor.

Remeber that HotText requires the MooTools More package (specifically the Drag class from that package), and of course the HotText source code must also be linked to before HotText can be used.