【问题标题】:Trying to get pagedown bootstrap to work on meteor text area试图让 pagedown 引导程序在流星文本区域上工作
【发布时间】:2014-08-25 01:04:30
【问题描述】:

我经常遇到 jquery 和 meteor 的这个问题,我得到一个 undefined is not a function,我就是不知道为什么。

这是我安装的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

【问题讨论】:

    标签: javascript jquery twitter-bootstrap meteor pagedown


    【解决方案1】:

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

    您需要查找具有可被其他变量访问的变量的文件。这里有两个问题涉及what meteor doeshow 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

    【讨论】:

    • 当我安装mrt时它在大气中可用添加pagedown-bootstrap它不是已经是一个包了。
    • @AndersKitson 我现在无法确定,过去几个小时我的气氛一直在下降,但如果你这样做了,那听起来是对的。只需检查您是否还使用 meteor list --using 将其添加为流星包(它在列表中吗?)
    • 是的,气氛一直很慢,但这是链接atmospherejs.com/package/pagedown-bootstrap,没有真正的文档。它显示在列表中。
    • @Akshat 我仍然遇到这个问题,我正在使用 atomsphere 的 pagedown-bootstrap 包。
    【解决方案2】:

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

    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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多