Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-1697

Add WebView "onlink" callback support

    Details

      Description

      Summary:
      We should add Ti.UI.WebView "onlink" callback support in view XML to make it more convenient to use. Currently, Alloy users are limited to assigning the callback in their JavaScript code instead.
      https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView-property-onlink

      Example:
      index.xml

      <Alloy>
      	<Window class="container">
      		<WebView id="webView" onlink="onLinkHandler"/>
      	</Window>
      </Alloy>
      

      index.js

      var htmlText =
      		'<!DOCTYPE html>\n' +
      		'<html>\n' +
      		'	<head>\n' +
      		'		<meta name="viewport" content="width=device-width, initial-scale=1.0">\n' +
      		'	</head>\n' +
      		'	<body>\n' +
      		'		<p>WebView "onlink" Test</p>\n' +
      		'		<br/>\n' +
      		'		<br/>\n' +
      		'		<a href="mylink://show/alert">Show Alert</a>\n' +
      		'	</body>\n' +
      		'</html>\n';
       
      function onLinkHandler(e) {
      	if (e.url === "mylink://show/alert") {
      		alert("The 'onLinkHandler' callback was invoked.");
      		return false;
      	}
      	return true;
      };
      $.webView.html = htmlText;
      $.index.open();
      

      Note:
      Currently, doing the above causes the "onlink" property to be assigned a string literal of the callback function like the below, which is invalid.

      $.webView.onlink = 'onLinkHandler';
      

        Attachments

          Activity

            People

            • Assignee:
              eharris Ewan Harris
              Reporter:
              gmathews Gary Mathews
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code