Create a WIN8 application using javascript+html (ii)

Source: Internet
Author: User

To add JavaScript Windows Library controls to our app, let's start by adding a scoring control in the previous demo

Unlike HTML controls, Windows Library controls for JavaScript do not have a dedicated markup element: for example, you cannot create rating controls by adding <rating/> elements. To add a Windows library control for JavaScript, you can create a DIV element and use the Data-win-control property to specify the type of control you want. To add a Rating control, set the property to "WinJS.UI.Rating".

  

The above code is our previous demo, unfamiliar to see the previous example

Operation Result:

  

Nothing happens when we manipulate the scoring control, and then we register the event with it

Open the Default.js file, add the following snippet, rating control has a Change event we register this event

1 function ratingchanged (eveninfo) 2     {3         var ratingoutput = document.getElementById ("Ratingoutput"); 4         Ratingoutput.innertext = "You have made a" +eveninfo.detail.tentativerating+ "evaluation of the Answer"; 5     }

How do you call this method?

1 app.onactivated = function (args) {2 if (args.detail.kind = = = Activation. Activationkind.launch) {3 if (args.detail.previousExecutionState!== activation. applicationexecutionstate.terminated) {4//TODO: This application just started. Initialize 5//your application here. 6} else {7//TODO: This application has been reactivated from the suspended state. 8//Restore application state here. 9}//The Change event for the rating control is registered here
Args.setpromise (WinJS.UI.processAll () then (function completed () {one-by-one var ratingcontroldiv = document.getElementById ("Ratingcontroldiv"); var Ratingcontrol = ratingcontroldiv.wincontrol;13 Ratingcontrol.addeventlistener ("Change", ratingchanged, False)); var Hellobutto n = document.getElementById ("Btnhello"); hellobutton.classname = "ButtonStyle"; hellobutton.ad Deventlistener ("Click", Buttonclickhandler, false); 19}20};

The results of the operation are as follows:

  

This is the first WIN8 application written in Html+javascript, referring to examples provided by Microsoft

This article is from the blog of Small Hui only, the original address: http://www.cnblogs.com/zhaohuionly/archive/2012/11/26/2788609.html

Create a WIN8 application using javascript+html (ii)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.