After the following code snippet is executed, the card is created but the checklist within this card is not. When creating the checklist, the success function is being called with x=0
Expected result: the newly created card should contain checklist with name "Sub Tasks". Why isn't it working?
var _newCard;
var name="card name";
var desc = "card description";
var boardId = some valisd board id;
Trello.post("lists/" + idList + "/cards", {
name: name,
desc: desc
}, function(card){
alert("Card was created");
_newCard = card;
});
Trello.post("checklists", {
name: "Sub Tasks",
idBoard: boardId
}, function(chklist) {
for (x in _newCard) {
//alert(x + " is " + _newCard[x]);
}
//alert("Checklist id: " + chklist.id);
Trello.post("cards/" + _newCard.id + "/checklists", {
value: chklist.id
}, function(suc) { for (x in suc) { alert(x + " is " + suc[x]); } }, function(err) { alert("Err: " + err) } )
})