Windows 8 Metro设置弹出窗口似乎无法在Javascript中运行? [英] Windows 8 Metro Settings Flyouts don't seem to work in Javascript?

查看:99
本文介绍了Windows 8 Metro设置弹出窗口似乎无法在Javascript中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在尝试为Windows 8创建Metro应用程序,并尝试使用弹出菜单.

I've recently been trying to create a metro app for Windows 8 and tried to use settings flyout.

所以我遵循了msdn快速入门: http://msdn. microsoft.com/en-us/library/windows/apps/hh780611.aspx

So I followed msdn quickstart: http://msdn.microsoft.com/en-us/library/windows/apps/hh780611.aspx

但是,我无法使其正常工作.

However, I can't make it work.

这是我添加设置弹出​​按钮的部分:

Here's the part where I add the settings flyout:

function setupSettings() {
    app.onsettings = function (e) {
        e.detail.applicationcommands = { 'serv_changer': { title: 'Change Server', href: 'settings.html' } };
        WinJS.UI.SettingsFlyout.populateSettings(e);
    }
}

当我按下一个按钮时,只会调用一次setupSettings函数(因此我可以确保它只执行一次)

The function setupSettings is called only once when I press a button (so I can make sure it only gets executed once)

这是我的问题:按下按钮后,更改服务器"链接出现.但是,当我单击它时,什么也没有发生,并且侧窗只是淡出了.

Here's my issue: after pressing the button, the "Change Server" link does appear. However, when I click on it, nothing happens and the side window just fades out.

这是我尝试过的事情,所以我知道这不是其中之一:

Here are the things I tried so I know it's not one of these:

  • 这不是文件丢失.我试图放入一个不存在的其他文件,并引发了异常,程序崩溃了.在这里,它不会崩溃.
  • HTML编码正确,因为我试图用Microsoft的示例设置文件之一替换settings.html.

我很难弄清楚为什么它不起作用.

I am having troubles figuring out why it does not work.

有人可以帮忙吗?(如果需要,我可以提供更多代码)?

Could somebody help (I can provide more code if needed) ?

谢谢.

推荐答案

在settings.html页面中,确保data-win-control声明包括设置commandId的名称-在线示例中似乎缺少此名称

In your settings.html page, make sure the data-win-control declaration includes setting the name of the commandId - this seems to be missing from the online example.

例如.

如果您的js文件将命令声明为:

If your js file declares the command as:

e.detail.applicationcommands = { 'serv_changer': { title: 'Change Server', href: 'settings.html' } };

...然后确保您的settings.html文件引用了"serv_changer":

...then make sure your settings.html file references 'serv_changer':

<div data-win-control="WinJS.UI.SettingsFlyout" data-win-options="{settingsCommandId:'serv_changer', width:'wide'}">

这篇关于Windows 8 Metro设置弹出窗口似乎无法在Javascript中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆