window.Event = new Vue(); Vue.component('region-select', { template: `
`, data() { return { regiones: [], isDefaultDisabled: 0, region: null } }, mounted() { axios.get("/api/regiones").then(response => this.regiones = response.data); }, methods: { onRegionSelected() { this.isDefaultDisabled = 1; Event.$emit("region-seleccionada",this.region); } } }); Vue.component('barrio-select', { template: `
`, data() { return { visible: false, region: null, gdcs: [], isDefaultDisabled: 0, gdc: null } }, mounted() { Event.$on('region-seleccionada', (region)=> { this.region = region; this.fillGDC(region); this.visible = true; }); }, methods : { fillGDC(region) { axios.get("/api/grupos-de-compra").then(response => { this.gdcs = response.data[this.region]; }); }, onGDCSelected() { this.isDefaultDisabled = 1; Event.$emit("gdc-seleccionado",this.gdc); } } }); Vue.component('login', { template: `

Si no la sabés, consultá a tus compañerxs.

`, data() { return { visible: false, gdc: null } }, mounted() { Event.$on('gdc-seleccionado', (gdc) => { this.gdc = gdc; this.visible = true; }); } }); new Vue({ el: '#root' });