diff --git a/src/mixins/ajax.js b/src/mixins/ajax.js index 6d9715d..b0c1787 100644 --- a/src/mixins/ajax.js +++ b/src/mixins/ajax.js @@ -33,9 +33,10 @@ module.exports = { * invoke the onSearch callback. */ search() { - if (this.search.length > 0 && this.onSearch) { + if (this.search.length > 0) { this.onSearch(this.search, this.toggleLoading) - } + this.$emit('search', this.search, this.toggleLoading) + } }, }, @@ -49,9 +50,9 @@ module.exports = { */ toggleLoading(toggle = null) { if (toggle == null) { - return this.showLoading = !this.showLoading + return this.mutableLoading = !this.mutableLoading } - return this.showLoading = toggle + return this.mutableLoading = toggle } } } diff --git a/test/unit/specs/Select.spec.js b/test/unit/specs/Select.spec.js index 8414a0d..5abe705 100644 --- a/test/unit/specs/Select.spec.js +++ b/test/unit/specs/Select.spec.js @@ -931,10 +931,10 @@ describe('Select.vue', () => { }).$mount() vm.$refs.select.toggleLoading() - expect(vm.$refs.select.showLoading).toEqual(true) + expect(vm.$refs.select.mutableLoading).toEqual(true) vm.$refs.select.toggleLoading(true) - expect(vm.$refs.select.showLoading).toEqual(true) + expect(vm.$refs.select.mutableLoading).toEqual(true) }) it('should trigger the onSearch callback when the search text changes', (done) => { @@ -980,6 +980,49 @@ describe('Select.vue', () => { }) }) + it('should trigger the search event when the search text changes', (done) => { + const vm = new Vue({ + template: '