The following mainly introduces the global methods in the script function. The global methods mainly include the following parts.
$(id:String); Get the control object
var button = $('test_button');
$C(XML:String); Create a control object through XML
var button = $C('<button id="test_button">按钮</button>'); //for ListItem var listItem = $C('<list-item><item href="detail.xml"><label>文本内容</label></item></list-item>'); //For GridItem var gridItem = $C('<grid-item><item href="detail.xml"><label>文本内容</label></item></grid-item>');
alert(text:String); prompt box
<button onclick="alert('logout')">Click the button</button>//As long as the controls with the onclick attribute can be used
alert(title|text:String); prompt box (with title)
<button onclick="alert('logout|logout')">click button</button>
confirm(title|text:String);Confirmation box (with title)
<?xml version="1.0" encoding="utf-8"?> <imag> <script> <![CDATA[ function testConfirm() { if (confirm('Logout | Are you sure?')) { hint('OK'); } else { hint('Cancel'); } } ]]> </script> <page> <title style="background:#acacac"> <center> <label>Global methods</label> </center> </title> <content draggable="true"> <button onclick="testConfirm()">click button</button> </content> </page> </imag>
full code