imag.js|Quickly grasp the global method

When using Ai Ma Ge for mobile application development, in addition to understanding basic content controls, form controls and layout controls, it is more important to master scripting functions. The script function is essential for interaction and invocation between interfaces. Making full use of the script function will make the app move instead of a simple static page. 
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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326673088&siteId=291194637
Recommended