-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Description
Hi!
I have a button with 3 states and want to refresh the 3rd state's icon with the count of features retrieved from backend.
So far I've tried updating the button.option.state[2].icon in a watcher, but... although the components option have been changed, the button itself doesn't refresh.
Any tips on how to force that refresh?
const _this = this
this.searchInArea = this.$leaflet.easyButton({
states: [{
stateName: 'search',
icon: `<i class="mdi mdi-map-search search-in-zone-btn text-primary">${this.$t('searchInZone')}</i>`,
title: _this.$t('searchInZone'),
onClick: (btn, map) => {
btn.state('loading')
_this.loadFeatures()
.then(() => {
btn.state('loaded')
})
}
}, {
stateName: 'loading',
icon: `<i class="search-in-zone-btn mdi mdi-loading mdi-spin">${this.$t('loading')}</i>`
}, {
stateName: 'loaded',
icon: `<i class="search-in-zone-btn">Showing ${_this.layerFeatures.length} features</i>`
}]
})
(....)
watch: {
layerFeatures() {
if (this.layerFeatures) {
this.searchInArea.options.states.find(st => st.stateName === 'loaded').icon = `<i class="search-in-zone-btn">Showing ${this.layerFeatures.length} features</i>`
}
}
}
Metadata
Metadata
Assignees
Labels
No labels