problem description
when editing bootstrap-editable, there are two ways to use it:
one is to edit and save directly in each column, for example :
{
title:"",
field:"title",
width:160,
align:"left",
valign:"middle",
sortable:false,
searchable:false,
editable: {
type: "text",
title: "",
mode: "popup",
emptytext: "--",
validate: function (v) {
if (!v) return "";
},
url:"/edit_todo",
success: function(response, newValue) {
if(response=="nouser"){
return "";
}
if(response=="7"){
return "";
}
if(response.status =="error") {
return response.msg;
}
}
}
},{
title:"",
field:"description",
align:"left",
valign:"middle",
sortable:false,
searchable:false,
width:400,
editable: {
type: "textarea",
title: "",
mode: "popup",
emptytext: "--"
url:"/edit_todo",
success: function(response, newValue) {
if(response=="nouser"){
return "";
}
if(response=="7"){
return "";
}
if(response.status =="error") {
return response.msg;
}
}
}
}
another way to edit and save in onEditableSave, for example:
onEditableSave: function (field, row, oldValue,$el) {
$.ajax({
type: "post",
url: "/edit_todo",
data: {
"pk":row.id,
"name":field,
"oldValue":oldValue,
"newValue":row[field]
},
success: function(data, status) {
if(status=="success"){
if (data == "nouser") {
return "";
}
if(data=="notallowed") {
return "";
}
if(data=="exHigh" || data == "Unresolved"|| data=="bug"){ //
$el.css("backgroundColor", "");
$el.removeClass("PinkBackground");
$el.removeClass("blueBackground");
$el.removeClass("greyBackground");
$el.addClass("redBackground");
}
else if(data=="High"){
$el.css("backgroundColor", "");
$el.removeClass("redBackground");
$el.removeClass("blueBackground");
$el.addClass("PinkBackground");
}
else {
$el.css("backgroundColor", "");
$el.removeClass("redBackground");
$el.removeClass("greyBackground");
$el.removeClass("PinkBackground");
$el.removeClass("blueBackground");
}
}
},
error: function () {
return"";
},
complete: function () {
}
question 1: in method 2, the value of oldValue can be read directly, while in method 1, the parameter name that goes to the background method is always name,value,pk,. Is there any way to pass in oldValue?
question 2: during the onEditableSave success callback, I need to prompt for an error message, as shown in figure
this function can be realized in method 1, but not in method 2.
how can prompt messages be displayed in method 2?