Layout events
Events in JavaScript are very useful when creating applications. DHTMLX has provided many different events for each of the components. We will go over how to attach and detach one of the events to give us an idea of how we can utilize them.
The more common events for the layout object are onResizeFinish
, onExpand
, onCollapse
, and onDblClick
. Let's take a look at onResizeFinish
.
We will use the same layout we created in previous sections to attach this event.
attachEvent and detachEvent
DHTMLX provides the
attachEvent
and detachEvent
methods.
The first parameter when attaching an event is the name of the event you want to attach. The second is a handler method, which is the method that will fire when the event triggers.
Type and run the following code:
var myEventId = myLayout.attachEvent("onResizeFinish", function(){ console.log("Layout Resized"); });
Now if you resize the browser window you will see a console entry stating Layout Resized.
In most cases the DHTMLX event will pass...