Using SweetAlert2 with vis.js

Viewed 253

To make items editable in vis.js, it uses callback which was okay with SweetAlert

I wanted to use SweetAlert2 to utilize its new features, however it is using Promise instead of callback and vis.js using callback!

Here is example code taken from http://visjs.org/examples/timeline/editing/editingItemsCallbacks.html:

Lines 47 to 57 and lines 129 to 137 where vis.js calling SweetAlert for prompt:

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

So how to modify this to use SweetAlert2?

1 Answers
Related