![](/img/trans.png)
[英]Is there any way to get the ID of a Trello card upon creating it using JavaScript?
[英]Get Trello card comments using Javascript / jQuery
我正在嘗試獲取卡片注釋,然后放入一些html標簽中。
我確實做到了(我想):
Trello.get("cards/6a7c530bce987f166f2272ef/actions", function(err, card) {
console.log(card); // I see the comments in console
$('#comments').html(card); // shows "success" in the page
})
在控制台中,我看到以下注釋:
但是我不知道如何使用“卡片”對象。 使用JSON.stringify(card)並登錄到conole,返回“成功”。
我嘗試了“ card [0]”,“ card ['text']”,“ card.text”,“ card.data.text”,但沒有任何效果。
因此,我需要幫助來從“卡片”對象或其他方式獲得卡片注釋。
更新:錯誤是函數參數的位置。 錯誤:“(錯誤,卡片)”。 正確:“(card,err)”。 要訪問特定的注釋,以下工作正常:
var last_comment = card[0]['data']['text']; // worked!!!
您發送的屏幕截圖顯示,請求返回了一組評論卡。 如果希望顯示所有注釋,則可以使用以下代碼:
Trello.get("cards/6a7c530bce987f166f2272ef/actions", function(err, comments) {
var html = "";
comments.forEach(function(comment) {
html += comment.data.text+"<br>";
}
$('#comments').html(html);
});
如果只需要數組中的第一個注釋,則可以執行以下操作:
Trello.get("cards/6a7c530bce987f166f2272ef/actions", function(err, comments) {
$('#comments').html(comments[0].data.text);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.