【问题标题】:undefined function with now.js on the client-side在客户端使用 now.js 的未定义函数
【发布时间】:2012-01-07 23:48:17
【问题描述】:

我正在使用 now.js 和 nano(CouchDB 库)来用选项填充选择。

服务器:

everyone.now.getThings = function(thing) {
  var self = this;
  return db.view('lists', 'some_things', function(error, data) {
    var list = data.rows.map(function(obj) {
      return '<option value="' + obj['id'] + '">' + obj['value'] + '</option>';
    });
    return self.now.receiveThings(list);
  });
};

客户:

$(document).ready(function() {
  now.getThings($('select#thing').val());

  $("#poke").click(function() {
    now.getThings($('select#thing').val());
  });
});

在客户端它说第一次调用“TypeError: 'undefined' is not a function”。在 .click()-Function 中一切正常。

now.js 在 application.js 之前加载。我也尝试了 $(now).ready(),但没有成功。

有什么问题?

【问题讨论】:

    标签: javascript node.js couchdb nowjs-sockets couchdb-nano


    【解决方案1】:

    我通过在翡翠模板调用中包含第一组数据并在 select 上创建了一个 .change() 处理程序来解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-05
      • 2021-04-16
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 2021-08-08
      • 2014-04-27
      • 1970-01-01
      相关资源
      最近更新 更多