Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- part of the vue template: the main element -->
- <!-- not working <button @click='$emit("open-modal-zone")'></button> -->
- <!-- not working <button @click='activateFilterModalViaEmit'></button> -->
- <modal-zone :filter-obj='filterObj' @open-modal-zone='modalActive=true' @close-modal-zone='modalActive=false' v-if='modalActive' ></modal-zone>
- <!-- the component in question -->
- Vue.component('modal-zone', {
- props : ["filterObj", "modalActive"],
- template: "<div id='modal-zone'>" +
- "<p @click='$emit("close-modal-zone")'>Close</p>" +
- "<filter-modal-dialog-controls :filter-obj='filterObj'></filter-modal-dialog-controls>" +
- "</div>"
- });
- <!-- filter-dialog-controls component omitted (I haven't gotten that far yet) -->
- // the vue js of my app
- var v = new Vue({
- el : "#editing-div",
- data : {
- modalActive : false,
- filterObj : {
- filterModalActive : false
- }
- },
- methods : {
- activateFilterModalViaEmit : function(){
- this.$emit("open-modal-zone"); //why doesn't this work?
- }
- activateFilterModal : function(){
- this.modalActive = true; // this works.. but I want $emit!
- }
- }
- });
Add Comment
Please, Sign In to add comment