0

我经常遇到 jquery 和流星的这个问题,我得到一个未定义的不是函数,我就是不知道为什么。

这是我安装的pagedown-bootstrap包的代码。错误的链接是正确的来源

Template.postSubmit.rendered = function () {



$("textarea#pagedownMe").pagedownBootstrap();

};

我的html模板

<template name="postSubmit">
  <form class="submitForm">

      <label for="date">Date</label>
      <input name="date" type="text" value="" placeholder="Date"/>


      <label for ="title">Title</label>
      <input name ="title" type="text" value="" placeholder="title"/>

      <label for="content">Content</label>
    <textarea id="pagedownMe" name="content"  class="form-control" rows="10">
This is the *first* editor.
------------------------------

Just plain **Markdown**, except that the input is sanitized:

<marquee>I'm the ghost from the past!</marquee>
</textarea>



      <input type="submit" value="Submit" />
  </form>
</template>

我得到的错误

Exception from Deps afterFlush function function: TypeError: undefined is not a function
    at Object.Template.postSubmit.rendered (http://localhost:3000/client/postsPagedown.js?05d5727bffc4120f5b1e1765e9451a7571bbd788:5:26)
    at http://localhost:3000/packages/ui.js?f0696b7e9407b8f11e5838e7e7820e9b6d7fc92f:426:23
    at _assign.flush (http://localhost:3000/packages/deps.js?91f1235baecd83915f7d3a7328526dbba41482be:345:13) 

来自大气的包装

主包pagedown-bootstrap 依赖标记

4

2 回答 2

1

看起来您需要将包转换为使用流星。要做的主要事情是主要变量的非变量范围。

您需要查找具有可被其他变量访问的变量的文件。这里有两个问题,涵盖了流星的基本功能以及如何通过它

我建议你把它做成一个 Meteor 包,其中包含 pagedown 包,其中的变量被修改为全局。这样,您可以将项目命名为远离您的应用程序的名称,并且仍然可以正常工作。

这是一个关于如何制作包的好教程:http: //www.vintyge.com/blog/2012/12/creating-a-basic-meteorite-smart-package

对所有链接感到抱歉,但查看包的源代码不会像复制和粘贴那么简单。


捷径,但有点奇怪的方式。

您可以将包文件放在/client/compatibility. 尽管您可能必须重命名文件,以便它们以正确的顺序加载。Meteor 按字母顺序加载文件,因此您必须重命名第一个文件a.js(Markdown.Converter.js - 我认为)和下一个b.js

于 2014-07-03T19:34:56.140 回答
0

我使用了错误的代码,我查看了错误的资源。

JS

$(function () {
     var converter = new Markdown.Converter();
     var editor = new Markdown.Editor(converter);
     editor.run();

HTML

<div class="wmd-panel">
     <div id="wmd-button-bar">
     </div>
     <textarea class="wmd-input" id="wmd-input">
This is the *first* editor.
------------------------------

Just plain **Markdown**, except that the input is sanitized:

<marquee>I'm the ghost from the past!</marquee>
     </textarea>
</div>
<div id="wmd-preview" class="wmd-panel wmd-preview">
</div>
于 2014-07-09T00:31:00.087 回答