function show_modal3(thisobj) {
var data = $table.bootstrapTable('getData');
var index = $(thisobj).parent("li").parent("ul").parent("div").parent("button").parent("td").parent("tr").data('index');
console.log("当前索引:"+index);
var dict=data[index];
var key="title";
if(dict.hasOwnProperty(key)){
var old_title=dict[key];
console.log("标题为:"+old_title);
}
$("#old_title").val(old_title);
$("#title_index").val(index);
$('#myModal3').modal('show');
}
function capitalize(str) {
if(true){
var array = str.toLowerCase().split(" ");
for (var i = 0; i < array.length; i++) {
array[i] = array[i][0].toUpperCase() + array[i].substring(1, array[i].length);
}
var string = array.join(" ");
return string;
}
}
$(function () {
$("#update_title").click(function () {
var new_title = $('#old_title').val();
new_title=capitalize(new_title);
console.log(new_title);
var title_index=$('#title_index').val();
var data = $table.bootstrapTable('getData');
var dict=data[title_index];
if(dict.hasOwnProperty("title")){
var old_title=dict["title"];
}
console.log(old_title)
if (!new_title) {
return 'This field is required';
}else if(old_title==new_title){
$('#myModal3').modal('hide');
}else{
if(dict.hasOwnProperty("product_id")){
var product_id=dict["product_id"];
}
if(dict.hasOwnProperty("sku")){
var sku=dict["sku"];
}
if(dict.hasOwnProperty("upload_user_id")){
var user_id=dict["upload_user_id"];
if(user_id==null){
if(dict.hasOwnProperty("store_id")){
user_id=dict["store_id"];
}
}
}
$.ajax({
type:"POST",
dataType:"json",
url:'/update_title/',
data: {
"csrfmiddlewaretoken":document.getElementsByName('csrfmiddlewaretoken')[0].value,
"product_id":product_id,
"sku":sku,
"name":"title",
"old":old_title,
"new":new_title,
"userId":user_id,
},
success:function () {
$('#myModal3').modal('hide');
},error:function () {
$('#myModal3').modal('hide');
},
})
}
});
});