2
为了使项目在vis.js编辑,它使用回调这是好与SweetAlert使用SweetAlert2与vis.js
我想用SweetAlert2利用其新的功能,但它是用承诺来代替回调可见。 js使用回调!
这里是http://visjs.org/examples/timeline/editing/editingItemsCallbacks.html所采取的示例代码:
线47至57和129行至137,其中vis.js呼吁SweetAlert的提示:
onAdd: function (item, callback) {
prettyPrompt('Add item', 'Enter text content for new item:', item.content, function (value) {
if (value) {
item.content = value;
callback(item); // send back adjusted new item
}
else {
callback(null); // cancel item creation
}
});
},
function prettyPrompt(title, text, inputValue, callback) {
swal({
title: title,
text: text,
type: 'input',
showCancelButton: true,
inputValue: inputValue
}, callback);
}
那么如何修改此使用SweetAlert2?