Question

I am playing around with using the WMD Editor (http://wmd-editor.com/) in my site. I have a really simple question. When I am ready to submit the text to the server; how do I get the output of the editor?

Something like this only returns the 'actual text that user typed in the textarea'

    var jtext = document.getElementById('myTextarea').value;

I would like to get the 'output' of the editor; but I can't figure out how to do that :(

By output; I mean the 'Markdown' or 'Html' output.

Was it helpful?

Solution

You will need to use javascript to get the contents of the preview div. Based on the demo on the wmd site, the div in question has the class wmd-preview. Not sure why it's not id'd.

In jQuery, you'd use something like:

$('#formname').submit(function() {
    $('#hidden_form_element').val($('.wmd-preview').html());
    return true;
});

OTHER TIPS

I believe you can simply make a textarea with the id="wmd-output", it should allows you to submit the output code

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top