From 0372c459fca3605011a08990f76db1a2995dff8e Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Wed, 23 Mar 2022 13:42:34 +0100 Subject: [PATCH] docs: remote webview, fix two errors (#13322) --- apidoc/Titanium/UI/OptionBar.yml | 6 +++--- apidoc/Titanium/UI/OptionDialog.yml | 2 +- apidoc/Titanium/UI/WebView.yml | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/apidoc/Titanium/UI/OptionBar.yml b/apidoc/Titanium/UI/OptionBar.yml index 02431449a9d..5d55fb9f4df 100644 --- a/apidoc/Titanium/UI/OptionBar.yml +++ b/apidoc/Titanium/UI/OptionBar.yml @@ -21,10 +21,10 @@ excludes: properties: [children] methods: [add, remove, removeAllChildren, replaceAt] -events: +events: - name: click summary: Fired when an option has been selected. - properties: + properties: - name: index summary: Index of the option clicked on. type: Number @@ -62,7 +62,7 @@ examples: ``` js const win = Ti.UI.createWindow(); const optionBar = Ti.UI.createOptionBar({ - labels: [ 'Option 1', 'Option 2', Option 3 ] + labels: [ 'Option 1', 'Option 2', 'Option 3' ] }); optionBar.addEventListener('click', (e) => { Ti.API.info(`Option ${e.index} was selected.`); diff --git a/apidoc/Titanium/UI/OptionDialog.yml b/apidoc/Titanium/UI/OptionDialog.yml index 15245827267..5a1a7c8d910 100644 --- a/apidoc/Titanium/UI/OptionDialog.yml +++ b/apidoc/Titanium/UI/OptionDialog.yml @@ -242,7 +242,7 @@ examples: - title: Dialog with 3 Options example: | ``` js - Ti.UI.setBackgroundColor('white'); + Ti.UI.backgroundColor = 'white'; var win = Ti.UI.createWindow({ title: 'Click window to test', backgroundColor: 'white' diff --git a/apidoc/Titanium/UI/WebView.yml b/apidoc/Titanium/UI/WebView.yml index df0938904b3..19df4882bec 100644 --- a/apidoc/Titanium/UI/WebView.yml +++ b/apidoc/Titanium/UI/WebView.yml @@ -35,6 +35,22 @@ description: | [evalJS](Titanium.UI.WebView.evalJS) method to execute a JavaScript expression inside the web view and retrieve the value of an expression. + You can inject the local `Ti.App.fireEvent` bindings yourself by adding a script element using + evalJS. + + ```js + webview.evalJS( + 'javascript=(function addBinding(){' + + 'var s=document.createElement("script");' + + 's.setAttribute("type","text/javascript");' + + 's.innerHTML="' + require('/binding.js') + '";' + + + 'document.getElementsByTagName("body")[0].appendChild(s);' + + '})()' + ); + ``` + The `binding.min.js` is available in the [repository](https://github.com/tidev/titanium_mobile/tree/master/android/modules/ui/assets/Resources/ti.internal/webview). + #### Local JavaScript Files During the build process for creating a package, all JavaScript files, that is, any file with a