在流星js中显示来自mongodb的Summernote内容时出错

时间:2018-05-04 10:45:54

标签: javascript meteor meteor-blaze summernote

我正在编写简单的博客应用程序,当我从db

加载时,我收到了错误

模板

<template name="view">
 <div>
         {{{ summernote }}}
 </div>
</template>

显示Mongodb .....

  <div class="container">
{{> editor}}

  {{#each post }} {{> view}} {{/each}}

main.js

if (Meteor.isClient) {

  Template.body.helpers({

    post: function () {

      return Post.find();
    }
  });

  Template.editor.onRendered(function () {
    $(document).ready(function () {
      $('#summernote').summernote({

        height: 300
      });
    });
  });

  Template.editor.events({
    'click #saveContent': function (e) {

      e.preventDefault();

      var summernote = $('#summernote').summernote('code');

      Meteor.call('posts.insert', summernote);
    }
  });
}

lib.js

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Mongo } from 'meteor/mongo';

export const Post = new Mongo.Collection('posts');

Meteor.methods({

  'posts.insert'(summernote) {

    check(summernote, String);
    Post.insert({
      summernote,
      createdAt: new Date()
    });
    console.log(summernote);
  }
});

我遇到了以下错误

排队任务中的​​例外:Spacebars.include@ http://localhost:3000/packages/spacebars.js?hash=547cf8e466d1d52603d19bd5f48fb5df184fd237:48:13     template.main.js / HTTP://本地主机:3000 /应用程序/ app.js散列= 47d4ac698c02f59520602a8871b3d5485a3a5b26:31:19     doRender @ http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:2086:20     viewAutorun / HTTP://本地主机:3000 /包/ blaze.js散列= a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1934:18     Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:3744:12     viewAutorun /&LT; @ http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1932:14     Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:2271:12     viewAutorun @ http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1931:12     Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?hash=0e8b5c18d543a28ce43b2f183c26b49ee62196af:339:5     Tracker.Computation@http://localhost:3000/packages/tracker.js?hash=0e8b5c18d543a28ce43b2f183c26b49ee62196af:229:5     Tracker.autorun@http://localhost:3000/packages/tracker.js?hash=0e8b5c18d543a28ce43b2f183c26b49ee62196af:613:11     Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:1944:14     Blaze._materializeView /&LT; @ http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:2080:5     Tracker.nonreactive@http://localhost:3000/packages/tracker.js?hash=0e8b5c18d543a28ce43b2f183c26b49ee62196af:640:12     Blaze._materializeView@http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:2079:3     addedAt /&LT; @ http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:2851:25     Tracker.nonreactive@http://localhost:3000/packages/tracker.js?hash=0e8b5c18d543a28ce43b2f183c26b49ee62196af:640:12     addedAt @ http://localhost:3000/packages/blaze.js?hash=a1ff2d6d5ecd59ee11e2ba260b8650a9d1140f59:2824:9     addedAt @ http://localhost:3000/packages/observe-sequence.js?hash=5da2e60ce61e074a6463979f3992dd5bac41b43d:373:9     addedBefore @ http://localhost:3000/packages/minimongo.js?hash=9d4bb4b714acae5bd3d70f96bb3803e155b57e38:3372:11     addedBefore @ http://localhost:3000/packages/minimongo.js?hash=9d4bb4b714acae5bd3d70f96bb3803e155b57e38:2836:13     wrapCallback / HTTP://本地主机:3000 /包/ minimongo.js哈希= 9d4bb4b714acae5bd3d70f96bb3803e155b57e38:1827:13     SQp.runTask@http://localhost:3000/packages/meteor.js?hash=c9a34f92f28ede5a42eac467d3fa1763b624436a:782:9     SQp.flush@http://localhost:3000/packages/meteor.js?hash=c9a34f92f28ede5a42eac467d3fa1763b624436a:811:3     SQp.drain@http://localhost:3000/packages/meteor.js?hash=c9a34f92f28ede5a42eac467d3fa1763b624436a:820:5     resumeObservers @ http://localhost:3000/packages/minimongo.js?hash=9d4bb4b714acae5bd3d70f96bb3803e155b57e38:2438:7     endUpdate @ http://localhost:3000/packages/mongo.js?hash=7dae0d2bbf4992c92bbb005435b6ee27a23d13b2:339:9     registerStore / HTTP://本地主机:3000 /包/ DDP-client.js散列= a547928b29e722e419948bbc25e954f2c268a1c3:631:20     _performWrites /&LT; @ http://localhost:3000/packages/ddp-client.js?hash=a547928b29e722e419948bbc25e954f2c268a1c3:1630:11     _performWrites @ http://localhost:3000/packages/ddp-client.js?hash=a547928b29e722e419948bbc25e954f2c268a1c3:1629:9     _flushBufferedWrites @ http://localhost:3000/packages/ddp-client.js?hash=a547928b29e722e419948bbc25e954f2c268a1c3:1587:7     _livedata_data @ http://localhost:3000/packages/ddp-client.js?hash=a547928b29e722e419948bbc25e954f2c268a1c3:1548:9     的onMessage @ http://localhost:3000/packages/ddp-client.js?hash=a547928b29e722e419948bbc25e954f2c268a1c3:2153:9     _launchConnection / this.socket.onmessage /&LT; @ http://localhost:3000/packages/socket-stream-client.js?hash=55bf4fc2eb00d41c79827f8ec3b3949bbec01ce1:261:13     forEachCallback @ http://localhost:3000/packages/socket-stream-client.js?hash=55bf4fc2eb00d41c79827f8ec3b3949bbec01ce1:355:7     _launchConnection/this.socket.onmessage@http://localhost:3000/packages/socket-stream-client.js?hash=55bf4fc2eb00d41c79827f8ec3b3949bbec01ce1:260:11     sockjs-0.3.4.js / SockJShttp://本地主机:3000 /包/插座流client.js散列= 55bf4fc2eb00d41c79827f8ec3b3949bbec01ce1:645:7     sockjs-0.3.4.js / SockJShttp://本地主机:3000 /包/插座流client.js散列= 55bf4fc2eb00d41c79827f8ec3b3949bbec01ce1:1824:5     sockjs-0.3.4.js / SockJShttp://本地主机:3000 /包/插座流client.js散列= 55bf4fc2eb00d41c79827f8ec3b3949bbec01ce1:1890:11     sockjs-0.3.4.js / SockJShttp://本地主机:3000 /包/插座流client.js散列= 55bf4fc2eb00d41c79827f8ec3b3949bbec01ce1:2048:7     meteor.js:992:11

1 个答案:

答案 0 :(得分:0)

使用

尝试使用您的方法
Post.insert({
      summernote: summernote,
      createdAt: new Date()
    });