aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 138 forks source link

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

Open martinshhh opened 6 years ago

martinshhh commented 6 years ago

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 commented 6 years ago

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.