在 CouchApp 中列出文档时出现问题
我遇到了一些麻烦,因为我无法找到资源和/或教程来为我提供足够的知识来正确执行此操作:
我正在联系人数据库上构建 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
仔细阅读这个教程有很大帮助。
Going over this Tutorial helped a lot.