Null Pointer
Null Pointer

Reputation: 9289

WinJS.UI.getControl in VS 11 Ultimate metro application

WinJS.UI.getControl is not defined in VS 11 Ultimate. Is there any alternatives there to do the same?

I mean, how can i access winJS controls in javascript?

Upvotes: 1

Views: 843

Answers (4)

harriha
harriha

Reputation: 301

Don't know whether this issue is still valid or not and what the original cause was, but anyway: it's good to remember that starting from the WinJS version shipped with Consumer Preview there is no WinJS.UI.getControl() function anymore, instead one should use syntax

var appBar = document.getElementById("appBar").winControl;

See the official migration guide for details.

Upvotes: 1

Richard Banks
Richard Banks

Reputation: 12546

@Null Pointer I notice that you've got another question about missing JS references in Metro apps. Personally, I've installed VS ultimate on a number of Windows 8 machines without a problem.

I'm wondering if you're installer had problems. Could you try doing an uninstall/reinstall of Visual Studio and seeing if that fixes things.

Also can you check the contents of the zip files in "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates\JavaScript\Windows Metro style\1033" and check that they contain the 9 standard JS files in them. If they are missing then your installer likely encountered a problem at some point.

Upvotes: 0

sarvesh
sarvesh

Reputation: 2743

Looks like there is a bug with JavaScript project template included with the ultimate edition, the winjs folder and the JavaScript files in the folder are not included by default.

Just copy that folder from the express edition or add it to the project template.

Upvotes: 0

Tiago Andrade e Silva
Tiago Andrade e Silva

Reputation: 976

There is no difference in the IDE in terms of your source code. Meaning there is no such thing as it is defined in Ultimate but not Express. VS Ultimate gives you more tools, but does not change the code you have (unless by using such tools :) ).

Make sure you have included ui.js

<script type="text/javascript" src="winjs/js/ui.js"></script>

You can use it like this:

var appBar = WinJS.UI.getControl(document.getElementById("appBar"));

Upvotes: 0

Related Questions