0

Though I use CouchDB-specific JQuery verison, the problem can appear to be not related to CouchDB. There is a list of document id's, and I'm using openDoc function from the docs to retrieve a document when user clicks the id:

$('.doc_name').click(function() {
    var doc_id = $(this).html().toString()
    console.log(doc_id);
    db.openDoc({
        ocId : doc_id,
        success : function(data) { console.log(data); }
    });
});

The rest of the code (66 lines) is here.

The console.log(doc_id) outputs a string, but I get an error: Uncaught TypeError: Object #<Object> has no method 'split' at the point where docId is processed.

What is the problem? Any suggestions?

martinthenext
  • 1,308
  • 1
  • 15
  • 28

1 Answers1

3

Move the docId to the first parameter of the openDoc call. Eg:

db.openDoc(doc_id, {
    success : function(data) { console.log(data); }
});

Here are some handy references for the jquery.couch.js file:

http://daleharvey.github.com/jquery.couch.js-docs/symbols/%24.couch.db.html#.openDoc

http://bradley-holt.com/2011/07/couchdb-jquery-plugin-reference/

Ryan Ramage
  • 2,606
  • 18
  • 17