سؤال

I'm using now.js with nano (CouchDB library) to fill a select with options.

Server:

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);
  });
};

Client:

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

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

On the client it says for the first call "TypeError: 'undefined' is not a function". Within the .click()-Function everything works fine.

now.js is loaded before application.js. I tried $(now).ready() as well, but it didn't work.

What's the problem?

هل كانت مفيدة؟

المحلول

I solved the problem by including the first set of data in the jade template call and created a .change()-handler on the select.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top