call this.$refs.paginate.selected from other component
Closed this issue · 2 comments
hamutaro89 commented
#HTML
<template id="A">
<paginate
:page-count="10"
:container-class="'pagination'"
:click-handler="pageEvent">
</paginate>
</template>
i'd wish to select page back to a number after getting callback, however the issue is my main method is calling from another component, the following way is not working when i called function abc().
var bus = new Vue();
Vue.component('A', {
template: '#A',
created{
bus.$on('test', function () {
this.$refs.paginate.selected = 5;
});
}
}
var vm = new Vue({
methods: {
abc(){
axios.get('url').then((response) => {
bus.$emit('test')
});
}
}
}
I tried to call it from the component itself and it works
Vue.component('A', {
template: '#A',
mounted(){
this.$refs.paginate.selected = 2;
}
}
Any helps?
lokyoung commented
Hello @hamutaro89 . So busy these days. Sorry for can't reply you in time. I think that's because you scope of your callback function.
Could you please try this
bus.$on('test', () => {
this.$refs.paginate.selected = 5;
});
lokyoung commented
Hello @hamutaro89 . Any problems just reopen this issue. Thanks.