无法调用方法'应用'未定义的jQuery Mobile

时间:2013-02-03 11:56:58

标签: jquery cordova jquery-mobile autocomplete

好的,所以我一直在研究承诺和未来...我现在想要实现的是使用自动完成JQM来填充输入字段,通过调用数据库并运行写的术语进入输入。我已将此网址用作参考:here但我似乎无法让它工作......我一直收到此错误:

Uncaught TypeError: Cannot call method 'apply' of undefined at file:///android_asset/www/js/q.js:1230

这是我的代码,因为它有点太大了,我在这里创建了一个链接:http://pastebin.com/Hh3CttMm

我的html ...这里是额外的JS文件:

var findClients = "SELECT clientname FROM clients WHERE uniqueName LIKE ? AND (clientState = 'NSW' OR clientState = 'MULTIPLE') LIMIT 5";

function listClients(text) {
  var clientArray = [];
  var queryDB = function queryDB(tx) {
    var term = "%" + text + "%";
    tx.executeSql(findClients, [term], createList, error2);
  }

  var createList = function createList (tx, results) {
    alert(results.row.length);
    for (var i = 0; i < results.rows.length; i++) {
      var item = results.rows.item(i);
      clientArray.push(item['clientname']);
    }

  }

  return Q.fcall(db.transaction(queryDB, error1)).then(function(){return clientArray});
}

我认为它与页面没有初始化我的Q.js文件有关,但我不太清楚如何解决这个问题。

编辑:错误在此函数中,在行throw error

Q.done = done;
function done(promise, fulfilled, rejected, progress) {
    var onUnhandledError = function (error) {
        // forward to a future turn so that ``when``
        // does not catch it and turn it into a rejection.
        nextTick(function () {
            makeStackTraceLong(error, promise);

            if (Q.onerror) {
                Q.onerror(error);
            } else {
                throw error;
            }
        });
    };

    // Avoid unnecessary `nextTick`ing via an unnecessary `when`.
    var promiseToHandle = fulfilled || rejected || progress ?
        when(promise, fulfilled, rejected, progress) :
        promise;

    if (typeof process === "object" && process && process.domain) {
        onUnhandledError = process.domain.bind(onUnhandledError);
    }
    fail(promiseToHandle, onUnhandledError);
}

0 个答案:

没有答案