I am using vis.js for a project that allows to dynamically add new items to the timeline, backed by a server/database. When such an item is created it is assigned a temporarily id. After it is synced with the server (using an Ajax call), a permanent id is assigned (by the server).
Currently, I am removing the item with the temporarily id, and add a new item with the permanent id.
But I was wondering if and how I can modify the temporarily id into the permanent one (without removing and adding the item)?
I looked at Editing Items, but I do not see how I could change the id of an item.
If the situation permits, mine does, it is possible to do synchronization with the server before accepting adding the item. The server then returns the expected id, which can be filled in the item before creating it.
For example:
onAdd = function(item, callback) {
if(syncWithServer(item)) {
item.id = getIdFromServerResponse();
callback(item);
} else {
// Cancel, something went wrong
callback(null);
}
}