0

I am fiddling around with a 'list'-function in couch handling linked documents. Documents and their linked 'neighbors' are screened. It works all fine.

So, I thought I would extend it a little and let some representative 'neighbor'-data be screened rather than the _id:xxx..

My thought was to use jQuery.ajax() and feed it the _id:xxx to return the data I wanted and then let the list-function send that to be screened.

In the top of the 'lib/lists.js' I place $=require('jQuery') and in the kanso.json the jquery package is included and 'installed' before the push but this only results in window not defined.

OK. It could be that there does not exist any window-object in the lists.js, but what to do then? Should I write an XHRHttpRequest in javascript directly or let lists.js result on a webpage where jQuery can be called in the <script>jQuery code here..</script> and find the elements wanted, read the _id:xxx, fetch wanted data and replace _id:xxx with the wanted data?

Both solutions seems rather 'write more, don't do so much actually'. Suggestions?

Pea-Pod
  • 79
  • 9
  • @Tushar I appreciate your concern with my spelling except that it causes confusion as the spelling is not mine. For future reference: http://kan.so/packages/details/jquery http://en.wiktionary.org/wiki/neighbour – Pea-Pod Sep 02 '13 at 18:04

2 Answers2

1

I encountered the same thing....
My workaround was to move the jquery Requires statement to my index.html page and reduce the require definition from

var db = require('db').current();

to

var db = require('db');

This worked, but I'm not saying its idiomatic.

CSSian
  • 1,621
  • 13
  • 19
0

Answer as far as I got it: No jQuery, no XHR, not anything side effecting in that direction in _list functions.

My solution: Write separate jQuery code requesting a view and then with the retrieved _id:s to the linked document do separate requests for data from linked docs.

Disclaimer: I have NOT been able to make $.couch.db().openDoc() return any document. Instead I used $.get() with great success.

Pea-Pod
  • 79
  • 9