我正在用JS函数在trello板上创建一个新的卡
var currentLocation = window.location.href;
function AddCardToTrello() {
Trello.addCard({
url: currentLocation,
name: "{{ soproduct.product }}",
due: {{ soproduct.required_date|date:"SHORT_DATE_FORMAT" }}
});
}在创建之后,我得到了一个Trello向导,其中显示了指向Trello板上新创建的卡的链接。我想要捕获此链接,并将其保存在我的背部。我该怎么做呢?是否可以从相同的API调用中捕获数据?
发布于 2016-08-01 05:25:59
我刚刚在Trello Sandbox上进行了测试:
var destinationList = "XX_YOUR_LIST_ID_XX";
var success = function(successMsg) {
asyncOutput(successMsg);
};
var error = function(errorMsg) {
asyncOutput(errorMsg);
};
var newCard =
{name: "I just created a new card!",
desc: "Using the Trello API is fun and easy!",
pos: "top",
due: null,
idList: destinationList
};
Trello.post('/cards/', newCard, success, error);successMsg回调值在对象中包含一个参数:
"url": "https://trello.com/c/PCJcEkmm/6-i-just-created-a-new-card"
因此,我的建议是将保存到后端的过程添加到你的成功函数中--这取决于你使用的插件/脚本架构。
var success = function(successMsg) {
console.log(successMsg);
//Save to storage here
};
var error = function(errorMsg) {
console.log(errorMsg);
};
function AddCardToTrello() {
Trello.addCard({
url: currentLocation,
name: "{{ soproduct.product }}",
due: {{ soproduct.required_date|date:"SHORT_DATE_FORMAT" }}
}, success, error);
}https://stackoverflow.com/questions/38687003
复制相似问题