Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table only updates when I update the fields from the first document #484

Open
martinshhh opened this issue Jan 19, 2018 · 1 comment
Open

Comments

@martinshhh
Copy link

I'm using aldeed:autoform to validade and update my collection.
I have Reactive Table displaying all the documents of my collection. When I click on a row, I have iron:router to set the template data context with the document:

this.route('formulario', {
        path: '/tabelas/:_id',
        data: function() {
            return Adverts.findOne(this.params._id);
        }

that sends to a template with autoform where I update the data in my collection.

<template name="formularioUpdate">
    {{> quickForm collection="Adverts" doc=this id="formularioUpdate" type="update"}}
</template>

The problem is that if I update the second row, the document gets updated in Mongo but nothing happens in ReactiveTable, but If I delete or edit the first one, it gets updated.
My table.js and html

Template.imoveis.helpers({
    table: function() {
        return Adverts.find().fetch();
     },
});

Template.imoveis.events({
    'click #dwnldFiles': function() {
       Meteor.call('downloadUpdatedXML', listaImoveis ,function(error, xml){
        console.log(xml)
        // saveAs(new Blob([xml], { type: 'application/octet-stream' }), 'FicheiroConvertido.xml')
       });
    },
    'click .reactive-table tbody tr': function(event) {
        Router.go('formulario', {_id: this._id});
    }
});
<div>
        {{> reactiveTable collection=table}}
</div>
@aslagle
Copy link
Owner

aslagle commented Jan 22, 2018

Hi @xMaarf, I think your problem might be that you're using Adverts.find().fetch() in your table function. This returns an array rather than the Meteor collection object so the table won't be able to get updates. I'm not sure why the first row works, but try using just Adverts instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants