admin管理员组文章数量:1394057
I am trying to get the date each card was created via the Trello API. In JSFiddle, I've used the test code from the Trello site, and am trying to add an alert to each card so when clicked it shows the user the created date of the card.
I don't think I have the syntax right, however:
$.each(cards, function(ix, card) {
$("<a>")
.addClass("card")
.text(card.name)
.appendTo($cards)
.click(function(){
alert(Trello.get("cards/" + card.id + "?action=createCard", { fields: "date" }));
})
The JSFiddle is here: /
I'm also not too sure what it should be returning which is making it tricky to debug. How do I access the object it returns?
I am trying to get the date each card was created via the Trello API. In JSFiddle, I've used the test code from the Trello site, and am trying to add an alert to each card so when clicked it shows the user the created date of the card.
I don't think I have the syntax right, however:
$.each(cards, function(ix, card) {
$("<a>")
.addClass("card")
.text(card.name)
.appendTo($cards)
.click(function(){
alert(Trello.get("cards/" + card.id + "?action=createCard", { fields: "date" }));
})
The JSFiddle is here: http://jsfiddle/bdgriffiths/E4rLn/392/
I'm also not too sure what it should be returning which is making it tricky to debug. How do I access the object it returns?
Share Improve this question asked Nov 17, 2013 at 10:23 BenBen 4,3199 gold badges69 silver badges105 bronze badges2 Answers
Reset to default 5Finally found an answer to this - the card created date is embedded in the card id!
How to get the time a card was created
Trello.get
is an asynchronous function. This is necessary, because it uses AJAX, which is asynchronous. This means that you need to pass it a callback; its return value is essentially meaningless. Changing your code to:
$.each(cards, function(ix, card) {
$("<a>")
.addClass("card")
.text(card.name)
.appendTo($cards)
.click(function(){
Trello.get("cards/" + card.id + "?action=createCard", { fields: "date" }, function(card) {
alert(card);
});
})
should fix it.
本文标签: javascriptHow do I get the card created date from the Trello APIStack Overflow
版权声明:本文标题:javascript - How do I get the card created date from the Trello API? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744579113a2613810.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论