簡體   English   中英

從addCard trello API創建trello卡后,如何捕獲其鏈接?

[英]How to capture link of a trello card after creating it from addCard trello API?

我正在使用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調用中捕獲數據?

我剛剛在Trello沙箱中對此進行了測試:

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);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM