Note that there are some explanatory texts on larger screens.

plurals
  1. POChange existing JavaScript object functions with prototype?
    primarykey
    data
    text
    <p>I'm trying to hook PageDown into my Rails app, because the Markdown editor is awesome.</p> <p>However, I'm finding this difficult because Rails auto-assigns ids via form helpers, and PageDown expects the id "wmd-input" to be assigned to a textarea field. In my model I have a text property named "body" that I want to serve as the editor, but <code>f.text_area :body</code> yields a textarea with the id <code>post_body</code>.</p> <p>So, my current approach is to tell PageDown to associate the editor with a textarea with a particular class name rather than associating it with a particular ID. This is where I'm confused as to how to proceed. Here's a <a href="http://code.google.com/p/pagedown/source/browse/Markdown.Editor.js?r=46bb422ffaa27b3a2895ff3ce8c31f8b491fa9a9" rel="nofollow">link to Markdown.Editor.js</a>.</p> <p>Navigate to <code>function PanelCollection(postfix) {</code> (on line 244). I want to change the third line in that function from:</p> <pre><code>this.input = doc.getElementById("wmd-input" + postfix); </code></pre> <p>to</p> <pre><code>this.input = doc.getElementsByClassName("wmd-input" + postfix)[0]; </code></pre> <p>I've never done anything like this. Also, editing the source for Markdown.Editor.js isn't really an option since it is auto-generated. I need to alter the function after it's been created. How can I do this?</p> <p><strong>EDIT #1:</strong></p> <p>So, this was my first time forking and contributing back to anything on GitHub, but I forked the pagedown-rails gem and made my change and ensured it worked by connecting the gem listed in my Gemfile to my fork. Worked beautifully, thanks for the suggestion. I contributed back <a href="https://github.com/rh/pagedown-rails/pull/2" rel="nofollow">via this pull request</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload