这是一个函数,在android项目的ssets \ www \ modules \ node \ node.js中获取drupal的web服务的节点。当我点击内容并尝试在Android模拟器中的应用程序中检索节点时,会出现错误消息“node_page_view引用错误:nid未定义”,应用程序似乎可以读取节点/%,所以我想调试函数,见警报(节点);在以下代码中。但我重新运行该计划,没有任何事情发生,任何想法?
function node_page_view(node) {
alert(node);
try {
if (drupalgap.settings.debug) {
console.log('node_page_view()');
console.log(JSON.stringify(arguments));
}
if (node) {
var build = {
'theme':'node',
'node':node, // TODO - is this line of code doing anything?
'title':{'markup':node.title}, // TODO - this is a core field and should probably by fetched from entity.js
'content':{'markup':node.content},
};
// If the comments are hidden, do nothing.
if (node.comment == 0) { }
// If the comments are closed or open, show the comments.
else if (node.comment == 1 || node.comment == 2) {
// Build an empty list for the comments
build.comments = {
'theme':'jqm_item_list',
'title':'Comments',
'items':[],
'attributes':{'id':'comment_listing_items'},
};
// If the comments are open, show the comment form.
if (node.comment == 2) {
build.comments_form = {
'markup':
'<h2>Add comment</h2>' +
drupalgap_get_form('comment_edit', {'nid':node.nid})
};
}
}
return build;
}
else {
alert('node_page_view - failed to load node (' + nid + ')');
}
}
catch (error) {
alert('node_page_view - ' + error);
}
}