Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5427] allow preventDefault method to work on native UI elements

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2011-10-04T15:34:41.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMatthew Apperson
AssigneeReggie Seagraves
Created2011-10-04T13:38:57.000+0000
Updated2014-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
}

Comments

  1. Don Thorp 2011-10-04

    That is a DOM method and not a JS method. An eventing system has to be designed in for Titanium.
  2. Blain Hamon 2011-10-06

    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."

JSON Source