Errore:impossibile eseguire "insertBefore" su "Node"

Ho provato a inserire <div> contenitori intorno a {{#each}} ma non ha funzionato altrettanto bene. È anche strano perché funziona per 2 normali pagine di elenco di post, ma non per la terza che le ordina in base alla distanza.

Aggiornamenti: Ho notato che dopo aver cambiato il modello JS da template.name.onRendered a onCreated , la pagina di ordinamento funziona. Tuttavia funziona solo se si passa da una pagina precedente dell'elenco dei post e non dalla pagina del profilo.

L'unico motivo comune delle pagine di errore è che le pagine utilizzano publishComposite per l'ordinamento. Potrebbe essere questo il problema dal momento che publishComposite ha una relazione da figlio a genitore?

Il messaggio di errore

Exception in queued task: Error: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
    at Error (native)
    at Object.container._uihooks.insertElement (http://localhost:3000/packages/meteoric_ionic.js?e45c114e85716d9fad8bac1cd7904ae2700bc963:5750:19)
    at DOMRange._insertNodeWithHooks (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:383:21)
    at Function.Blaze._DOMRange._insertNodeWithHooks (http://localhost:3000/packages/peerlibrary_blaze-components.js?4eddb4e3f0f660190548347e680d109a51a7050f:2377:10)
    at Function.DOMRange._insert (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:354:16)
    at DOMRange.attach (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:431:16)
    at Blaze._DOMRange.attach (http://localhost:3000/packages/peerlibrary_blaze-components.js?4eddb4e3f0f660190548347e680d109a51a7050f:2437:33)
    at Function.DOMRange._insert (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:349:7)
    at DOMRange.attach (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:431:16)
    at Blaze._DOMRange.attach (http://localhost:3000/packages/peerlibrary_blaze-components.js?4eddb4e3f0f660190548347e680d109a51a7050f:2437:33)

Il file js meteoric_ionic si riferiva alla riga 19

container._uihooks = {                                                                                               
    insertElement: function(node, next) {                                                                              
      var $node = $(node);                                                                                             
      if (!template.transition || !$node.hasClass('view') || IonNavigation.skipTransitions) {                         
        container.insertBefore(node, next);  //line 19                                                                          
        return;                                                                                                        
      }  

L'html pertinente

  {{#ionView}}
    {{#ionContent}}
        {{#ionList}}
            <div>
              {{#each shops}}
                    {{> shopItem}}
              {{/each}}
            </div>
        {{/ionList}}
    {{/ionContent}}
  {{/ionView}}

Risposta

Prova questo e fammi sapere:

Template.nearShops.onCreated(function () {  
  var self = this;
  self.autorun(function () {
    self.interval = Meteor.setInterval(function(){
      var currentLocation = Geolocation.latLng() || '';
      if(currentLocation) {
        Session.set('lat', currentLocation.lat);
        Session.set('lng', currentLocation.lng);
      }
    }, 2000);   
  });
  self.autorun(function(){  
    if(Session.get('lat')) {
      self.subscribe( "nearShops", Session.get('lng'), Session.get('lat') );
    }
  });
});

Farò una spiegazione se funziona