【问题标题】:Meteor Deps Recompute FailsMeteor Deps 重新计算失败
【发布时间】:2013-06-04 12:01:53
【问题描述】:

单击上一个按钮将检索上一个日期的集合。例如,如果当前日期是 2013-04-05,则上一个按钮将检索 2013-04-04 的所有集合,依此类推。但是,自动更新不起作用。新的事件集合从未出现并发生异常。

此外,如果我尝试创建新事件,我也会遇到此错误。只有刷新页面才能看到集合中的新事件。

错误

Exception from Deps recompute: Error: Error copying attribute ',': Error:     InvalidCharacterError: DOM Exception 5
at Function.Spark._Patcher._copyAttributes (http://0.0.0.0:3000/packages/spark/patch.js?   e76412b922e47b6c2c1f890e3bc10fd13bdecfef:494:19)
at Spark._Patcher.match (http://0.0.0.0:3000/packages/spark/patch.js?e76412b922e47b6c2c1f890e3bc10fd13bdecfef:249:26)
at http://0.0.0.0:3000/packages/spark/patch.js?e76412b922e47b6c2c1f890e3bc10fd13bdecfef:61:23
at visitNodes (http://0.0.0.0:3000/packages/spark/patch.js?e76412b922e47b6c2c1f890e3bc10fd13bdecfef:17:11)
at Object.Spark._patch (http://0.0.0.0:3000/packages/spark/patch.js?e76412b922e47b6c2c1f890e3bc10fd13bdecfef:31:3)
at http://0.0.0.0:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:638:13
at LiveRange.operate (http://0.0.0.0:3000/packages/liverange/liverange.js?5e6bc5ba11645802c3440658c75fcc2277537dd1:458:9)
at http://0.0.0.0:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:633:11
at withEventGuard (http://0.0.0.0:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:103:16)
at Object.Spark.renderToRange (http://0.0.0.0:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:632:3) logging.js:40

Exception from Deps afterFlush function: TypeError: Cannot read property 'previousSibling' of null
at findPosition (http://0.0.0.0:3000/packages/liverange/liverange.js?5e6bc5ba11645802c3440658c75fcc2277537dd1:177:12)
at new LiveRange (http://0.0.0.0:3000/packages/liverange/liverange.js?5e6bc5ba11645802c3440658c75fcc2277537dd1:126:18)
at notifyWatchers (http://0.0.0.0:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:86:19)
at http://0.0.0.0:3000/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:404:5
at _.extend.flush (http://0.0.0.0:3000/packages/deps/deps.js?651e87591167f4286e96438ff2566ba3357bff99:231:11) 

查找事件列表的代码,else下的代码是相关部分

Template.event_manager.list = () ->
   if (Session.get("events_toggl"))
     Events.find({user_id: Meteor.userId()}, {sort: {seconds: 1}})
   else
     d = Session.get("eventnav")
     start = moment().subtract("days",d).startOf("day")._d
     end = moment().subtract("days", d).endOf("end")._d
     Events.find({user_id: Meteor.userId(), date: {$gte: start, $lt: end} })

点击上一个会触发上面列表函数的更新

'click #previous' : () ->
    d = Session.get("eventnav")
    d += 1
    Session.set("eventnav", d)

我们决定渲染事件列表的部分

  {{#each list}}
    {{> event}}
  {{/each}}

个别活动的模板

<template name="event">
  <tr class={{status}}>
    <td>{{seconds}}</td>
    <td><p id="date-{{_id}}" class="date">{{date}}</p></td>
    <td><p id="name-{{_id}}" class="name">{{name}}</p></td>
    <td><input type="button" id="select" value="select" /><br /><br /><input type="button" id="destroy" value="delete" /></td>
  </tr>
 </template>

【问题讨论】:

    标签: meteor


    【解决方案1】:

    我遇到了同样的错误,只是多个 id 具有相同的值。

    http://www.meteorpedia.com/read/TypeError_-_Cannot_read_property_nodeName_of_null

    【讨论】:

      【解决方案2】:

      解决了我的问题。事实证明该错误与无效的 HTML 按钮有关。

      <input type="button", id="previous", value="previous" />
      <input type="button", id="next", value="forward" />
      

      简单的解决方法是删除所有逗号。

      【讨论】:

        【解决方案3】:

        我没有重复的 id,但删除列表元素的 id 属性解决了这个问题:

        错误的 HTML:

          {{#each formDatas}}
          <tr class="formDataRow" id="{{_id}}">
             {{#each ../this}}
             <td>{{getData ../this this }}</td>
             {{/each}}
             <td><input id="{{_id}}" class="row-selector" type="checkbox"></td>
          </tr>
          {{/each}}
        

        不会导致错误的HTML

          {{#each formDatas}}
          <tr class="formDataRow" id="{{_id}}">
             {{#each ../this}}
             <td>{{getData ../this this }}</td>
             {{/each}}
             <td><input class="row-selector" type="checkbox"></td>
          </tr>
          {{/each}}
        

        注意input 中缺少的id 属性

        您通常不需要id 属性,因为事件中的this 对象指的是循环的数据元素

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-04-21
          • 1970-01-01
          • 1970-01-01
          • 2015-07-11
          • 1970-01-01
          相关资源
          最近更新 更多