Created
February 22, 2018 08:45
-
-
Save anonymous/4b060d7e174d9ea6edf7bf30ca35ba70 to your computer and use it in GitHub Desktop.
Testing Dynamic Buttons Click event in VueJs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>My first Vue app</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script src="https://unpkg.com/vue"></script> | |
</head> | |
<body> | |
<div id="app"> | |
{{ message }} | |
<button v-on:click="sayHi">Say Hi</button> | |
<button v-on:click="createNewBtn">Create a dynamic button</button> | |
</div> | |
<script> | |
(function(){ | |
var app = new Vue({ | |
el: '#app', | |
data: { | |
message: 'Hello Vue!' | |
}, | |
methods: { | |
sayHi: function () { | |
alert("hi") | |
}, | |
createNewBtn : function(){ | |
$("#app").append("<button v-on:click='sayHi'>Dynamically added Button click event not working</button>"); | |
} | |
} | |
}) | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment