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>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
  
  <div id="app">
        <h3 v-if="!isEditing">{{ submittedRoomName }}</h3>
        <input type="text" v-model="roomName" v-else>
        <button @click="edit" v-if="!isEditing">Edit</button>
        <button @click="save" v-if="isEditing">Save</button>
        <button @click="cancel" v-if="isEditing">Cancel</button>
  </div>
</body>
</html>
 
new Vue({
  el: '#app',
  data: {
    submittedRoomName: null,
    roomName: 'initial room name',
    isEditing: false
  },
  mounted () {
    this.submittedRoomName = this.roomName
  },
  methods: {
    edit () {
      this.isEditing = true
    },
    save () {
      this.submittedRoomName = this.roomName
      this.isEditing = false
    },
    cancel () {
      this.roomName = this.submittedRoomName
      this.isEditing = false
    }
  }
})
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers