Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div id="app">
    
    <ul>
      <li v-for="(input, index) in inputs">
        <input type="text" v-model="input.one"> - {{ input.one }}  
        <input type="text" v-model="input.two"> - {{ input.two }}
        
        <a v-if="input.video === null" v-on:click="addVideo(input);" style="cursor: pointer">Add Video element</a>
        <template v-else>
            <input type="text" v-model="input.video">
            <a v-on:click="removeVideo(input);" style="cursor: pointer">Remove Video element</a>
        </template>
        <br>
        <button @click="deleteRow(index)">Delete</button>
      </li>
    </ul>
    
    <button @click="addRow">Add row</button>
    
  </div>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
  
</body>
</html>
 
const app = new Vue({
  
  el: '#app',
  
  data: {
    inputs: []
  },
  
  methods: {
    addRow() {
      this.inputs.push({
        one: '',
        two: '',
        video: null                     // added
      })
    },
    addVideo(input) {
      input.video = '';                 // changed
    },
    removeVideo(input) {
      input.video = null;               // added
    },
    deleteRow(index) {
      this.inputs.splice(index,1)
    }
  }
  
})
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers