Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <script>
  2.  
  3. export default{
  4. props: [
  5. 'club', 'title'
  6. ],
  7. created(){
  8.  
  9. //Get club list
  10. this.$http.get('/api/clubs', function(data) {
  11. this.clubs = data;
  12. console.log(data);
  13.  
  14. //read active club from parent
  15. this.selected = this.$parent.$parent.active_club;
  16. });
  17.  
  18. },
  19. data(){
  20. return{
  21. clubs: [],
  22. selected: null,
  23. }
  24. },
  25. watch: {
  26. selected: function(v) {
  27. this.club = v;
  28.  
  29. //Post to database selected club
  30. this.$http.post('/api/clubs/' + v + '/active')
  31.  
  32. },
  33. club: function(v) {
  34. this.selected = v;
  35.  
  36. //Change active_club at parent (THIS NOT WORKING)
  37. // this.$emit('active_club', v);
  38. // this.$parent.active_club = v;
  39. club.$emit('active_club', v);
  40.  
  41. },
  42. }
  43.  
  44. }
  45. </script>
  46.  
  47. const app = new Vue({
  48. router,
  49. data() {
  50. return {
  51. user: [],
  52. active_club: null,
  53. ranking: null
  54. }
  55. },
  56. created: function() {
  57. var self = this;
  58.  
  59. this.$http.get('/api/users/me', function(data) {
  60. this.user = data;
  61. self.active_club = data.active_club;
  62.  
  63. })
  64.  
  65. }
  66.  
  67.  
  68. }).$mount('#app');
  69.  
  70. const club = new Vue();
  71.  
  72. //THIS NOT WORKING
  73. club.$on('active_club', function (id) {
  74.  
  75. alert(id)
  76. this.active_club = id;
  77. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement