6. More About Events and Actions
Conditional Events
<< Editable ListBox   |   Back to Main   |   Trigger-Delayed Events >>

View Source
will open in a new window
Making Events Conditional
Somtimes we want events to trigger conditionally. Given our editable listbox, a good example of this is that we want the submitting of the new Item to only happen if the user has typed in something in the textbox.

Basically, if the textbox is blank, no event should trigger. (You can verify this now by clicking "Add Item" without while keeping the textbox completely blank.)

Qcodo supports this by allowing all events to have optional conditions. These conditions are written as custom javascript code into the Event constructor itself.

In this example, we explicitly name the textbox's ControlId as "txtItem" so that we can write custom javascript as conditionals to the button's QClickEvent and the textbox's QEnterKeyEvent.