[TIMOB-5427] allow preventDefault method to work on native UI elements
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2011-10-04T15:34:41.000+0000 |
Affected Version/s | Release 1.7.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Matthew Apperson |
Assignee | Reggie Seagraves |
Created | 2011-10-04T13:38:57.000+0000 |
Updated | 2014-06-19T12:46:40.000+0000 |
Description
Currently the JS preventDefault method is not supported, and we recommend using a view under a view, and set touchEnabled to false on the top view, and deal with the click on the underlying elements.
for instance, a click event listener on an alert dialog cant do this:
if (ev.index == 1) { // clicked "learn more"
Ti.Platform.openURL('http://www.xyz.com');
ev.preventDefault(); //this should prevent the dialog from closing
}
That is a DOM method and not a JS method. An eventing system has to be designed in for Titanium.
Not only that, but even the duplicate is an invalid request. The events are asynchronous--that is, by the time the JS has run, the native code handling it has already happened. Not only that, events are often are asynchronous for the native app portion. For example, on an alert, iOS only tells us that a button was pressed after it's already dismissed the alert. Note http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIAlertViewDelegate_Protocol/UIAlertViewDelegate/UIAlertViewDelegate.html "The receiver is automatically dismissed after this method is invoked."