Editor not closing and can't be re-opend upon successfull ajax edit/add
Editor not closing and can't be re-opend upon successfull ajax edit/add
As per the subject, when I add or edit the datatable everything works fine until the response comes back from the server (data was properly updated on the backed). At this time, neither the 'Add' nor 'Edit' modals disappear. Also at this time, I am no longer able to pull up the add/edit/delete modals. It's as if the DataTables plugin gets stuck in a certain state. Deleting multiple times works fine.
Summary:
- page loads, datatable populates with expected data
- delete a user, works fine
- delete another user, works fine
- add/edit a user, user info saved to backend but modal doesn't close. no errors reported
- clicking add/edit/delete no longer does anything
My guess is that there is a problem with the returned JSON but I've inspected it using Chrome and this is my returned JSON:
{"data":[{"DT_RowId":"row_8","id":"user-be469311-17c2-4991-9a01-fbf11953644f","name":"zzz user","email":"test@test2.com","phone":"5555555555","password":"","companyId":"aeryon-labs","eula":false,"disabled":false,"pilot":false,"group":"","company":""}]}
This JSON appears to meet the requirements for what is expected in the response. Is there any other known reasons for the editor interface to operate this way?
In case it's relevant, here's the code I used for the edit button:
edit: {
type: 'PUT',
url: "/api/admin/user",
data: function(row) {
var user = row["data"];
var userInfo;
var userId;
// extract the user information from the row -- this may change when the returned data set is changed
for (var key in user) {
if(user.hasOwnProperty(key)) {
userId = key;
userInfo = user[key];
break;
}
}
var name = userInfo["name"];
var email = userInfo["email"];
var phone = userInfo["phone"];
var companyId = userInfo["companyId"];
var company = userInfo["company"];
var group = userInfo["group"];
var pilot = userInfo["pilot"];
var disabled = userInfo["disabled"];
var userInfoJSON = {"id":userId, "submitType": "edit", "name":name, "email":email, "phone":phone, "companyId":companyId, "company":company, "group":group, "pilot":pilot, "disabled": disabled }
return JSON.stringify(userInfoJSON);
},
dataType: "json",
contentType: "application/json",
processData: true,
cache: false,
success: function(data) {
table.ajax.reload();
//editor.close();
},
error: function() {
//should be able to handle errors if we return the proper json object from the server -- requires errors[]
}
I tried to setup a test for demo purposes (actual site isn't available publicly) but we are using React and I wasn't able to get a valid test going. I've added as much code as possible to give an idea of what I'm doing. Hopefully this will be enough.