Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

undefined function with now.js on the client-side

undefined function with now.js on the client-side

Problem

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

Problem courtesy of: Patrick

Solution

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

Solution courtesy of: Patrick

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

undefined function with now.js on the client-side

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×