Reputation: 2258
I'm playing around with the cool Aurelia UI-Virtualization plugin (https://github.com/aurelia/ui-virtualization) to provide a user with a list of search results.
If they do a new search, I want to replace the current results with the new ones. I would think you just need to set the array to the new results, but that creates some weird behavior, kind of like the list is "remembering" it's old contents.
In my case, when you click on one of the search results, a separate panel shows details about that search result. But after a rebind, it shows info about the old result still.
Thanks!
Aaron
Upvotes: 0
Views: 346
Reputation: 793
i managed to solve a similar problem using signals:
http://aurelia.io/hub.html#/doc/article/aurelia/binding/latest/binding-binding-behaviors/5
search.js:
import {inject} from 'aurelia-framework'
import {BindingSignaler} from 'aurelia-templating-resources'
export class Search
{
static inject() { return [BindingSignaler] }
constructor(signaler)
{
this.signaler = signaler
}
search()
{
// do your thing
this.searchresults = [ /* searchresults here */ ]
this.signaler.signal('update-results')
}
}
search.html
<template>
<div repeat.for="item in searchresults & signal:'update-results'">
${ item }
</div>
</template>
Upvotes: 2