views:

163

answers:

1

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.

+4  A: 

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;
});
Ryan Graham
Thanks.. thats what I was not sure about. I was looking for a actual function call or something. So the right thing to do is to save the 'value of the textarea' and the 'value of the preview div'..
shergill
There you go. Added some sample code.
Ryan Graham