在客户端使用now.js的未定义函数



我现在使用nano .js (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'不是一个函数"。在.click()-函数中一切正常。

now.js在application.js之前加载。我也尝试了$(now).ready(),但它不起作用。

有什么问题吗?

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

最新更新