Win8: Add winjs control Win8: Hello gril

Source: Internet
Author: User
ArticleDirectory
    • Add a winjs control using tags
    • Set winjs control attributes in tag
    • Process winjs control events
    • Method 2: Add a winjs control using code

In factWin8: Hello grilYou have added the winjs rating control. Now let's take a brief look at how to add the winjs control.

Check: http://msdn.microsoft.com/en-us/library/windows/apps/hh465493.aspx

Add a winjs control using tags

Unlike HTML controls, Windows library controls for JavaScript do not have dedicated tag elements. For example, you cannot add <rating/> elements to createRatingControl. To add a Windows library control for Javascript, you can createDivElement and useData-win-controlProperty specifies the required control type. To addRatingControl. Set this attribute to "winjs. UI. rating ".

You must alsoCodeCallingWinjs. UI. processallFunction.Winjs. UI. processallAnalyze your tag and instantiate any Windows library controls it finds for JavaScript.

Set winjs control attributes in tag

Unlike HTML controls, Windows library controls for JavaScript do not have dedicated element or attribute tags. For example, you cannot use the following tagsRatingControl setting properties:

 

 
<! --Not valid markup.--><RatingMaxrating= "10"Averagerating= "6" />

 

SwitchData-win-OptionsSet Properties in the tag. It uses a string containing one or more attribute/value pairs (separated by commas ):

 

 
<Div id = "ratingcontrolhost" data-win-control = "winjs. UI. rating"Data-Win-Options = "{maxrating: 10, averagerating: 6}"> </div>

 

Process winjs control events
    1. In JavaScript, retrieve the host element of the control and use itsWincontrolProperty to retrieve the control.
    2. TheAddeventlistenerFunction and specify an event and an event for processing.Program.

 

Args. setpromise (winjs. UI. processall (). Then (Function(){VaRControl = Document. getelementbyid ("ratingcontrolhost"). Wincontrol; control. addeventlistener ("Change", ratingchanged,False);}));

 

Be sure to run the command after the asynchronous winjs. UI. processall () operation. Ratingchanged is the processing method.

Method 2: Add a winjs control using code

 

 

 

 

 

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.