javascript - 尝试让 pagedown Bootstrap 在 meteor 文本区域上工作

标签 javascript jquery twitter-bootstrap meteor pagedown

我经常在使用jquery和meteor时遇到这个问题,我得到一个未定义的不是一个函数,我只是不明白为什么。

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

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依赖marked

最佳答案

看起来您需要转换包才能与 meteor 一起使用。主要要做的就是主变量的作用域不可变。

您需要查找包含可被其他变量访问的变量的文件。这里有两个问题,涉及 what meteor does 的基础知识。和 how to get passed it

我建议你将其设为 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

关于javascript - 尝试让 pagedown Bootstrap 在 meteor 文本区域上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24561620/

相关文章:

javascript - Grunt 排除在构建期间连接一些文件

javascript - 解析json错误

javascript - 使用 jquery 创建简单的缩略图网格扩展预览

css - Bootstrap 4 无效反馈,输入组未显示

javascript - Bootstrap float 导航栏和 anchor 对齐

javascript - 道场:道场/文本和 CORS

javascript - jquery mobile 或 javascript 中的放大和缩小功能

javascript - 设置属性值的 Ember 问题

jquery错误: Object expected

jquery - 使用 Twitter Bootstrap 自动启动和停止 YouTube 视频