Simplemde-markdown-editor: Adding SimpleMDE on multiple textareas

Created on 7 Jan 2016  路  2Comments  路  Source: sparksuite/simplemde-markdown-editor

I'd like to add SimpleMDE to 6 textareas in a page.
What is the best way?

My idea is:

var simplemde = new SimpleMDE({ element: $(".simplemde")[0,1,2,3,4,5] });  

Will this work or any better way to do it?

Most helpful comment

Ok, I found the solution in another thread.

$('textarea').each(function() {
    var simplemde = new SimpleMDE({
        element: this,
    });
    simplemde.render(); 
})

Thank you!

All 2 comments

Ok, I found the solution in another thread.

$('textarea').each(function() {
    var simplemde = new SimpleMDE({
        element: this,
    });
    simplemde.render(); 
})

Thank you!

i correct this, for the new version

JQuery

$('textarea').each(element => {
  const simplemde = new SimpleMDE({
    element: element,
  });
});

Js

[].forEach.call(document.getElementsByTagName('textarea'),element => {
  const simplemde = new SimpleMDE({
    element: element,
  });
});

The simplemde.render(); is not needed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elsuxo picture elsuxo  路  3Comments

rodsimpson picture rodsimpson  路  3Comments

mbeckenbach picture mbeckenbach  路  4Comments

christianmalek picture christianmalek  路  5Comments

liniu picture liniu  路  3Comments