在 CouchApp 中列出文档时出现问题

发布于 2024-10-16 20:29:18 字数 1491 浏览 2 评论 0原文

我遇到了一些麻烦,因为我无法找到资源和/或教程来为我提供足够的知识来正确执行此操作:

我正在联系人数据库上构建 Couchapp。为此,我需要在登陆页面上有一个无序列表的联系人(仅姓名)。在检查了相当长一段时间并检查了 http://kansojs.org 框架之后,我想我可能不得不问在 Stackoverflow 上,这是如何正确完成的...

这是我最终得到的结果(不起作用):

我开始设置一个视图(文件“views/contactslist/map.js”):

function(doc) {
  if (doc.displayName) {
    emit(doc.displayName, {displayname: doc.displayName});
  }
};

...这基本上给了我这个响应:

{"total_rows":606,"offset":0,"rows":[
{{"id":"478d86edbbd94bbe627f3ebda309db7c","key":"Al Yankovic","value":{"displayname":"Al Yankovic"}},
{"id":"478d86edbbd94bbe627f3ebda30bb5cb","key":"Al-Qaeda","value":{"displayname":"Al-Qaeda"}}
]}

之后,我在 evently 目录“contacts”中创建了一个新目录,并创建了文件“mustache.html”、“data.js”和“query.json”:

mustache.html:

<ul>
  {{#contacts}}
    <li>
        <div class="name">
          {{displayname}}
        </div>
      <div style="clear:left;"></div>
    </li>
  {{/contacts}}
</ul>

data.js:

function(data) {
  $.log(data)
  var p;
  return {contacts : data.rows};
};

query.json :

{
  "view" : "contactslist",
  "descending" : "true"
}

然后我补充了 和 $("#contacts").evently("联系人", 应用程序); 到_attachments 目录中的index.html。

在 Firebug 中观看控制台,我看不到来自 CouchDB 的任何请求/响应返回我的 vie 结果,所以我认为它甚至没有被请求。我哪里走错了?

I am in a bit of trouble as I am not able to find resources and/or tutorials that give me enough knowledge how to do this properly:

I am building a Couchapp uppon a contact database. For this I need to have a unordered list of the contacts(only the names) on the landing page. After examining this now for quite a time and examining the http://kansojs.org framework, I think I might have to ask here at Stackoverflow how this is done properly...

Here is what I ended up with (not working):

I started to setup a view (file 'views/contactslist/map.js ):

function(doc) {
  if (doc.displayName) {
    emit(doc.displayName, {displayname: doc.displayName});
  }
};

... which basically gives me back this response:

{"total_rows":606,"offset":0,"rows":[
{{"id":"478d86edbbd94bbe627f3ebda309db7c","key":"Al Yankovic","value":{"displayname":"Al Yankovic"}},
{"id":"478d86edbbd94bbe627f3ebda30bb5cb","key":"Al-Qaeda","value":{"displayname":"Al-Qaeda"}}
]}

Afterwards, I created a new directory in the evently directory, 'contacts' and created the files "mustache.html", "data.js" and "query.json":

mustache.html:

<ul>
  {{#contacts}}
    <li>
        <div class="name">
          {{displayname}}
        </div>
      <div style="clear:left;"></div>
    </li>
  {{/contacts}}
</ul>

data.js:

function(data) {
  $.log(data)
  var p;
  return {contacts : data.rows};
};

query.json:

{
  "view" : "contactslist",
  "descending" : "true"
}

Then I added

and
$("#contacts").evently("contacts", app);
to the index.html in the _attachments directory.

Watching the console in Firebug I can not see any Request/Response from CouchDB returning my vie's results, so I think it is not even requested. Where did I take the wrong turn?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

魄砕の薆 2024-10-23 20:29:18

data.js、query.json 和 Mustache.html 需要位于 evently/contacts/_init/

_init 中,这意味着它会在小部件初始化时执行。

data.js, query.json and mustache.html need to be in evently/contacts/_init/

_init means that this gets executed on widget initialization.

决绝 2024-10-23 20:29:18

仔细阅读这个教程有很大帮助。

Going over this Tutorial helped a lot.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文