DHTMLX TOUCH allows to handle different events using its event handling system.
There are 2 ways to add a handler to the event:
1. The method attachEvent()
You can attach several handlers to the same event and detach them using two respective methods:
//to attach event var myEvent = $$("someComponentId").attachEvent("onItemClick", function (){ //event handler code }) //to detach event $$("someComponentId").detachEvent(myEvent);
2. The parameter 'on'
With help of the parameter on you can attach any event(s) to the related component. But you can't detach them later.
dhx.ui({ view:"list", ... on:{"itemClick": function(){alert("item has just been clicked");}} );
All events with subword 'onbefore' can be cancelled. To cancel event you should return false within the appropriate event handler.
var myEvent = $$("someComponentId").attachEvent("onBeforeTabClick", function (){ ...// some event handler code return false; })
Inside event handler you can refer to the holder component through keyword this.
Besides, most event handlers get incoming argument(s), like id of grid's row (see API Reference to know exactly what arguments are passed inside event handler).
Btw, using id of sub-element you can access data item associated with it and all its properties, even if they were not used to draw the element. For example:
$$("mylist").attachEvent("onafterselect",function(id){ $$("top_label").setValue(this.item(id).name) })
Button click event handling is realized through the parameter click. All you need is to set this parameter to the desired handler function.
The technique in question can be applied to any button:
{view:"button", label:"Close", align:"right", click:"someFunction" }
By default, DHTMLX Touch doesn't support keyboard events. But you can add such events to the desired component using the following code:
dhx.extend($$("componentId"), dhx.KeyEvents);
2 events will be added to the component:
//adds key events to 'Input' control with id:"input_1" dhx.extend($$("input_1"), dhx.KeyEvents); $$("input_1").attachEvent("onKeyPress",function(key){ alert(key); });
TOUCH events are blockable.
To block/unblock event you should use one of the appropriate methods:
$$("someComponentId").blockEvent();
$$("someComponentId").unblockEvent();