-
Notifications
You must be signed in to change notification settings - Fork 34
CONTROLS
Daniel Spors edited this page Nov 4, 2020
·
1 revision
Controls are a way to create custom UI logic without the need of a template. Sounds complicated, here's how:
Control::Make('h1')->append("Hello World!");
The Control class is the base for all kind of controls. You may use it for your own too:
class AjaxRepeater extends Control
{
function __initialize()
{
parent::__initialize('div');
$this->script("wdf.get('#{self}/delayload',function(d){ $('#{self}').html(d); })");
}
function DelayLoad()
{
$result = Control::Make();
foreach( DataSource::Get()->Query('mytable')->limit(10) as $item )
Control::Make('span')->append($item->name)->appendTo($result);
return $result;
}
}
This will create a DIV that loads it's contents once the page has been loaded. You can find some predefined controls in the lib/controls folder in the wdf repository. Of course you may subclass all of them to enrich their behaviour.