javascript – 错误:无法在’Node’上执行’insertBefore’

前端之家收集整理的这篇文章主要介绍了javascript – 错误:无法在’Node’上执行’insertBefore’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我试图插入< div> {{#each}}周围的容器,但它不起作用.它也很奇怪,因为它适用于2个普通帖子列表页面,但不适用于按距离对它们进行排序的第3个页面.

更新:
我注意到,在将模板JS从template.name.onRendered更改为onCreated之后,排序页面正常工作.但是,只有从先前的帖子列表页面而不是从个人资料页面开始,它才有效.

错误页面的唯一共同点是那些页面使用publishComposite进行排序.这可能是问题,因为publishComposite有一个子到父关系?

错误消息

  1. 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.
  2. at Error (native)
  3. at Object.container._uihooks.insertElement (http://localhost:3000/packages/meteoric_ionic.js?e45c114e85716d9fad8bac1cd7904ae2700bc963:5750:19)
  4. at DOMRange._insertNodeWithHooks (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:383:21)
  5. at Function.Blaze._DOMRange._insertNodeWithHooks (http://localhost:3000/packages/peerlibrary_blaze-components.js?4eddb4e3f0f660190548347e680d109a51a7050f:2377:10)
  6. at Function.DOMRange._insert (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:354:16)
  7. at DOMRange.attach (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:431:16)
  8. at Blaze._DOMRange.attach (http://localhost:3000/packages/peerlibrary_blaze-components.js?4eddb4e3f0f660190548347e680d109a51a7050f:2437:33)
  9. at Function.DOMRange._insert (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:349:7)
  10. at DOMRange.attach (http://localhost:3000/packages/blaze.js?695c7798b7f4eebed3f8ce0cbb17c21748ff8ba8:431:16)
  11. at Blaze._DOMRange.attach (http://localhost:3000/packages/peerlibrary_blaze-components.js?4eddb4e3f0f660190548347e680d109a51a7050f:2437:33)

meteoric_ionic js文件引用第19行

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

相关的HTML

  1. {{#ionView}}
  2. {{#ionContent}}
  3. {{#ionList}}
最佳答案
试试这个让我知道:

  1. Template.nearShops.onCreated(function () {
  2. var self = this;
  3. self.autorun(function () {
  4. self.interval = Meteor.setInterval(function(){
  5. var currentLocation = Geolocation.latLng() || '';
  6. if(currentLocation) {
  7. Session.set('lat',currentLocation.lat);
  8. Session.set('lng',currentLocation.lng);
  9. }
  10. },2000);
  11. });
  12. self.autorun(function(){
  13. if(Session.get('lat')) {
  14. self.subscribe( "nearShops",Session.get('lng'),Session.get('lat') );
  15. }
  16. });
  17. });

如果这项工作,我会解释

猜你在找的JavaScript相关文章