简体   繁体   English

在页面加载上使用spinnerPlugin会出错。

[英]Using spinnerPlugin on page load is giving error.

I have 2 pages. 我有2页。 Index.html and detail.html. Index.html和detail.html。 On index.html, when I click login, I call this function 在index.html上,当我单击登录时,我调用此函数

$('form').submit(function (event) { //Trigger on form submit        
    var options = { dimBackground: true };
    SpinnerPlugin.activityStart("Loading...", options);
});

It works perfectly. 它运作完美。 But on detail.html, I call this 但是在detail.html上,我称之为

$(document).ready(function () {
    var options = { dimBackground: true };
    SpinnerPlugin.activityStart("Loading...", options);
});

And it gives me the following error. 它给了我以下错误。

Uncaught ReferenceError: SpinnerPlugin is not defined 未捕获的ReferenceError:未定义SpinnerPlugin

I have installed the SpinnerPlugin using xml as well. 我也使用xml安装了SpinnerPlugin。 Wat should I do? 我该怎么办? Why is it working on index.html and not on detail.html? 为什么在index.html而不是detail.html上起作用?

Spinner plugin will only be available after the device ready event. Spinner插件仅在设备就绪事件后可用。 This means that you should wrap your code with it: 这意味着您应该用它包装代码:

$(document).ready(function () {
  document.addEventListener("deviceready", onDeviceReady, false);
});

function onDeviceReady() {
  var options = { dimBackground: true };
  SpinnerPlugin.activityStart("Loading...", options);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM