一起使用 JQuery-Mobile/Phonegap 的正确方法? [英] Correct way of using JQuery-Mobile/Phonegap together?

查看:26
本文介绍了一起使用 JQuery-Mobile/Phonegap 的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结合使用 JQuery Mobile 和 Phonegap 的正确方法是什么(到目前为止)?

What is the correct way (to this date) to use JQuery Mobile and Phonegap together?

两个框架都需要加载才能使用.在我可以使用它们之前,如何确保它们都已加载?

Both frameworks need to load before they can be used. How can I be sure that both are loaded before I can use them?

推荐答案

您可以使用 JQuery 的延迟特性.

You can use deferred feature of JQuery.

var deviceReadyDeferred = $.Deferred();
var jqmReadyDeferred = $.Deferred();

document.addEventListener("deviceReady", deviceReady, false);

function deviceReady() {
  deviceReadyDeferred.resolve();
}

$(document).one("mobileinit", function () {
  jqmReadyDeferred.resolve();
});

$.when(deviceReadyDeferred, jqmReadyDeferred).then(doWhenBothFrameworksLoaded);

function doWhenBothFrameworksLoaded() {
  // TBD
}

这篇关于一起使用 JQuery-Mobile/Phonegap 的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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