Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (65 sloc) 1.86 KB
<div id="app">
<h1>Tasks - edit</h1>
<hr />
<h1>title : {{ item.title }}</h1>
<div v-text="item.content"></div>
<div class="container">
<div class="form-group">
<label for="TopicTitle">タイトル</label>
<input type="text" class="form-control" id="title" v-model="title" >
</div>
<div class="form-group">
<label for="TopicContent">content</label>
<textarea class="form-control" id="content" rows="3" v-model="content"></textarea>
</div>
<button v-on:click="updateTask">更新</button>
<hr />
<button v-on:click="deleteTask">[ delete ]</button>
</div>
</div>
<!-- -->
<script>
new Vue({
el: '#app',
created () {
this.id = "<%= params_id %>";
this.getItem( this.id)
},
data: {
item : [],
title:'',
content:'',
id: 0,
},
methods: {
getItem: function(id) {
axios.get("/api/tasks_show/" + id )
.then(res => {
// var dat = res.data.docs
var dat = res.data.result
this.item = dat;
this.title = this.item.title
this.content = this.item.content
console.log( dat )
})
},
updateTask: function () {
var task = {
'id' : this.id,
'title': this.title,
'content': this.content
};
axios.post('/api/tasks_update/', task ).then(res => {
console.log(res.data );
});
},
deleteTask: function () {
axios.get("/api/tasks_delete/" +this.id )
.then(res => {
console.log( res.data )
window.location.href = '/tasks';
})
}
}
});
</script>
You can’t perform that action at this time.