Guest User

Untitled

a guest
Jul 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <!-- part of the vue template: the main element -->
  2. <!-- not working <button @click='$emit("open-modal-zone")'></button> -->
  3. <!-- not working <button @click='activateFilterModalViaEmit'></button> -->
  4. <modal-zone :filter-obj='filterObj' @open-modal-zone='modalActive=true' @close-modal-zone='modalActive=false' v-if='modalActive' ></modal-zone>
  5.  
  6. <!-- the component in question -->
  7. Vue.component('modal-zone', {
  8. props : ["filterObj", "modalActive"],
  9. template: "<div id='modal-zone'>" +
  10. "<p @click='$emit("close-modal-zone")'>Close</p>" +
  11. "<filter-modal-dialog-controls :filter-obj='filterObj'></filter-modal-dialog-controls>" +
  12. "</div>"
  13. });
  14.  
  15. <!-- filter-dialog-controls component omitted (I haven't gotten that far yet) -->
  16.  
  17. // the vue js of my app
  18. var v = new Vue({
  19. el : "#editing-div",
  20. data : {
  21. modalActive : false,
  22. filterObj : {
  23. filterModalActive : false
  24. }
  25. },
  26. methods : {
  27. activateFilterModalViaEmit : function(){
  28. this.$emit("open-modal-zone"); //why doesn't this work?
  29. }
  30. activateFilterModal : function(){
  31. this.modalActive = true; // this works.. but I want $emit!
  32. }
  33. }
  34. });
Add Comment
Please, Sign In to add comment