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
- In JavaScript, retrieve the host element of the control and use itsWincontrolProperty to retrieve the control.
- 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