You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
Binding events adds the event listener to the object. Unbinding removes the listener. Events can be chained.
Titanium Code
var scrollview = Titanium.UI.createScrollView();
scrollview.addEventListener('click', function() {
// do something
});
scrollview.addEventListener('dblclick', function() {
scrollview.removeEventListener('click');
});
TiQuery
var scrollview = $.ScrollView();
$(scrollview).bind('click', function() {
// do something
}).bind('dblclick', function() {
$(scrollview).unbind('click');
});
Triggering Events
Events can be triggered through the code using $(element).trigger();
Titanium
scrollview.fireEvent('click');
TiQuery
$(scrollview).trigger('click');
Event Shortcuts
TiQuery adds shortcuts to common events so that you don't have to type as much. For example:
$(scrollview).click(function() {
alert('I was clicked');
});
That will bind a click event to the scrollview. If you don't pass a parameter into the shortcut then it will trigger the event. The following example would trigger the click event on the scrollview.
$(scrollview).click();
Here are all of the available shortcuts:
blur
cancel
click
dblclick
doubletap
focus
orientationchange
scroll
shake
singletap
swipe
touchcancel
touchend
touchmove
touchstart
twofingertap
Registering event shortcuts
You can register shortcuts for your own events using registerEvent.
$.registerEvent('myEvent');
$(scrollview).myEvent(function() {
// do something
});
$(scrollview).myEvent();