Parse platform 我的if语句是否在做我认为它在做的事情?
这里我有一个函数,它可以查询数据并将其返回给我,我将数据放入html元素中以发表文章。我在底部的if语句中遇到了一点问题,我试图在新克隆被推到名为story board的新div后,仅将我的注释窗口应用于新克隆,我相信我在告诉我的if语句,如果这个类已经存在于这个新的克隆中,那么就不要再做其他的事情了。。看看我在说什么…这是我的测试领域。。。 登录是kio pass也是一样的,当你点击新闻发布时,每当一个nw-one点击时,它就会将评论框应用到已经有评论文本区域的故事板窗口中的一篇文章。我做错了什么Parse platform 我的if语句是否在做我认为它在做的事情?,parse-platform,Parse Platform,这里我有一个函数,它可以查询数据并将其返回给我,我将数据放入html元素中以发表文章。我在底部的if语句中遇到了一点问题,我试图在新克隆被推到名为story board的新div后,仅将我的注释窗口应用于新克隆,我相信我在告诉我的if语句,如果这个类已经存在于这个新的克隆中,那么就不要再做其他的事情了。。看看我在说什么…这是我的测试领域。。。 登录是kio pass也是一样的,当你点击新闻发布时,每当一个nw-one点击时,它就会将评论框应用到已经有评论文本区域的故事板窗口中的一篇文章。我做错了
function publishWindowHandler(){
var query = new Parse.Query('Post');
console.log(currentUser);
query.equalTo("User", currentUser);
query.include("User");
query.descending("createdAt")
console.log(user.get('username'));
query.find({
success:function(results){
document.getElementById("publishCenter").textContent = "";
for(var i =0; i < results.length; i++){
var userPost = results[i];
//console.log(userPost.get("User") + " / " + userPost.get("Author") + " / " + userPost.get("Story") + " / " + userPost.get("objectId"));
var authorTitle = document.createElement("p");
var newPost = document.createElement("P");
var title = document.createElement("P");
var userLabel = document.createElement("p");
var postId = userPost.id;
var postBtn = document.createElement("INPUT");
postBtn.className ="publishBtn";
postBtn.id ="publishBtn";
postBtn.setAttribute("Type", "button");
postBtn.setAttribute("value", "Publish");
title.textContent = "Story: " + userPost.get("Title");
authorTitle.textContent = "Author: " + userPost.get("Author");
newPost.textContent = userPost.get("Story");
userLabel.textContent = "Published by: " +userPost.get("User").get ("username");
var postWrapper = document.createElement("DIV");
postWrapper.className = "postWrapper";
postWrapper.id = postId;
document.getElementById("publishCenter").appendChild(postWrapper);
postWrapper.appendChild(title);
postWrapper.appendChild(authorTitle);
postWrapper.appendChild(newPost);
postWrapper.appendChild(userLabel);
postWrapper.appendChild(postBtn);
postBtn.addEventListener("click", publicViewHandler);
function publicViewHandler(){
$(this).parent(".postWrapper").clone().appendTo(".storyBoard");
function testWindow(){
if($(publicBoard).children().hasClass(".commentWindow")){
}
else
{
$(".storyBoard").children().append(commentWindow);
}
}
testWindow();
}
}
}
})
}根据文档,jquery hasClass不需要在传入的类名前加“.” 试着把它去掉,看看你有没有用 另外,变量commentWindow在哪里定义?它是全球性的吗
var myClone = $(this).parent().clone(true);
myClone.appendTo(".storyBoard");
console.log(publicBoard);
console.log("hello",$(this));
console.log($(publicBoard).find('.postWrapper').find("commentWindow"));
myClone.append($(commentWindow).clone());
这就是我为解决我的问题所做的事情,花了我一段时间和一位朋友的一点帮助