Skip to content

Instantly share code, notes, and snippets.

@jagroop
Created July 30, 2018 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagroop/86606c9076d8c9d15364b7f3dfa56153 to your computer and use it in GitHub Desktop.
Save jagroop/86606c9076d8c9d15364b7f3dfa56153 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
</head>
<body>
<div id="app">
<ul v-for="(post, index) in posts">
<li>
<div>
<p contenteditable="true" v-text="post.title" @input="updateContent(post.id, $event)">
</p>
</div>
</li>
</ul>
</div>
<script>
var app = new Vue({
el: '#app',
data() {
return {
posts: [
{id: 1, title: 'flow', status: true},
{id: 2, title: 'brother', status: true},
{id: 3, title: 'shelter', status: true},
{id: 4, title: 'slow', status: true},
{id: 5, title: 'kids', status: true},
{id: 6, title: 'announced', status: true},
{id: 7, title: 'night', status: true},
{id: 8, title: 'carry', status: true},
{id: 9, title: 'shown', status: true}
]
}
},
methods: {
updateContent(post_id, e) {
var content = e.target.innerHTML.replace(/^\|+|\|+$/g, '');
console.log(content, post_id);
}
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment