在後臺修改前臺模板檔案
阿新 • • 發佈:2019-02-02
<textarea cols= '80' rows='20'>${data['content']}</textarea>
<button onclick='change()' >修改</button>
`
}
}
})
}
function back(){
document.body.innerHTML = '';
// 未解決 : 返回上級目錄 dirname錯亂
/*var str = '';
var a = _this.getAttribute('data-dirname');
if(a.includes('/')){
str = a.substring(0,(a.indexOf('/')));
console.log(a);
console.log(str);
}*/
$.ajax({
url:'/admin/views',
type:'post',
data:{
dirname: '',
dirtype: '2'
},
success(data){
for(let i in data['content']){
// 下一級目錄
if(data.content[i].includes('.')){
document.body.innerHTML += `<p data-dirtype='1' onclick='next(this)' >${data.content[i]}</p>`;
}else{
document.body.innerHTML += `<p data-dirtype='2' onclick='next(this)' >${data.content[i]}</p>`;
}
}
}
})
}
function change(){
console.log($('textarea').val());
$.ajax({
url:'/admin/views',
type:"post",
data:{
dirname:dirname,
dirtype:'3',
content: $('textarea').val()
},
success(data){
alert(data.result);
}
})
}