Solved: How to refresh a CustomElement

I have an element which displays the contents of an array via ‘repeat for’

I want to refresh the element when the array is sorted

I used the Binding engine’s Collection Observer to know when the array changes

But I can’t figure out how to actually force a redraw of the Custom Element

I’ve even set the array = [] and then re-connected it to the source in a TaskQueue.queueTask

What is the command to tell Aurelia to redraw a custom element>

1 Like

Solved (without a solution)

I was calling resort on the array before the binding had updated on the control that modified the sort order

Once the timing of the resort request was corrected it was enough just to observe (with a no-op function) to get the refresh to work automatically

this.bindingEngine.collectionObserver(this.items).subscribe(() => { })

I love Aurelia – whenever I can’t make something work, I’m just trying too hard!!

7 Likes