Skip to content

Instantly share code, notes, and snippets.

@Hateman31
Created November 5, 2018 16:56
Show Gist options
  • Select an option

  • Save Hateman31/f07b78b5b8a7540fe938ae1ea0ee41a5 to your computer and use it in GitHub Desktop.

Select an option

Save Hateman31/f07b78b5b8a7540fe938ae1ea0ee41a5 to your computer and use it in GitHub Desktop.
editable table
<!--
index.html
Copyright 2017 vlad <vlad@vlad-Presario-CQ58-Notebook-PC>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Vue-test</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 1.23.1" />
</head>
<body>
<div id="app">
<div v-for="row in table">
<div @change="row.editable = !row.editable" v-if="row.editable">
<select v-model="row.selected">
<option
v-for="elem,index in row.options"
:value="index"
>{{elem.value}}</option>
</select>
</div>
<div @click="row.editable = !row.editable" v-else>
<label>{{row.options[row.selected].value}}</label>
</div>
</div>
</div>
<script src="vue.js"></script>
<script>
new Vue({
el:"#app",
data: {
table : [
{
selected:2,
editable: false,
options: [
{value:'a',selected:0},
{value:'b',selected:0},
{value:'c',selected:1}
]
},
{
selected:2,
editable: false,
options: [
{value:'a',selected:0},
{value:'b',selected:0},
{value:'c',selected:1}
]
},
]
}
});
</script>
<!-- <script src="app.js"></script> -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment