简体   繁体   中英

Using spinnerPlugin on page load is giving error.

I have 2 pages. Index.html and detail.html. On index.html, when I click login, I call this function

$('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

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

And it gives me the following error.

Uncaught ReferenceError: SpinnerPlugin is not defined

I have installed the SpinnerPlugin using xml as well. Wat should I do? Why is it working on index.html and not on detail.html?

Spinner plugin will only be available after the device ready event. 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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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