Closed dnish closed 8 years ago
This isn't enough. I need a repro. On Mar 5, 2016 11:10 AM, "dnish" notifications@github.com wrote:
Hey Manuel, it's me again, I've faced with another problem. I've added a search to our project, you can check it out here: www.convert.as/search
Now this is what happens: Type in a title into the search input and click f.e. on the second item. After that, the conversion should start. Then change your search to another title and click on the new second item again. This doesn't work anymore. You can click on all other items, but not on the second one.
This also happens if you click at the beginning on the first item and after a change of the search title again on the first, etc....
This is the important part of my template
{{#if results}}
{{#each results}} {{>search_item}} {{/each}} ```
{{/if}}
I don't know why this happens, I get no error console message. — Reply to this email directly or view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/200.
Okay, will try to make a repo. The only thing I now see is that the failed ViewModel still has the same porpertie, f.e. if I do
ViewModel.find("search_item")[0].started()
...is it always true, even if I get new results. The default value for a new VM is false. The funny thing is that wen I do ViewModel.find("search_item")[0].title()
I get the correct title....
I'm seeing that on a new search onRendered()
isn't executed on any of the new items. Also all ViewModels still have the same id's, even if results change. Do you know any situation where this can happen? On my repro with a light search example this doesn't happen. I'm fetching my results from a Meteor method. This is how I set the results:
Template.search.viewmodel({
results: null,
searchText: null,
onCreated() {
$("#wrapper").removeClass("toggled");
},
onRendered() {
},
autorun: [
function () {
if (this.searchText()) {
Meteor.call("search", this.searchText(), (err, res) => {
if (res.hasOwnProperty("items")) this.results(res.items);
});
}
}
]
});
I will now extend my repro.
@ManuelDeLeon Repro is available here: https://github.com/dnish/vm-search-repro
It "works" when you add a timeout:
Template.index.viewmodel({
search:null,
results:null,
doSearch() {
Meteor.call("getResults", (err,res) => {
this.results(null);
window.setTimeout(() => {
this.results(res);
},5000);
});
}
});
Your collection needs to have an _id
field.
This isn't a ViewModel issue. You'll get the same behavior in Blaze or React.
Ah thanks, I didn't know that.
Hey Manuel, it's me again, I've faced with another problem. I've added a search to our project.
Now this is what happens: Type in a title into the search input and click f.e. on the second item. After that, the conversion should start. Then change your search to another title and click on the new second item again. This doesn't work anymore. You can click on all other items, but not on the second one.
This also happens if you click at the beginning on the first item and after a change of the search title again on the first, etc....
This is the part of my template where I generate the item models:
I don't know why this happens, I get no error console message.