I'm currently evaluating MarkdownDeep for use on my website. Above the editor I display a list of images the user previously uploaded. To insert the image (which is wrapped in a link to the larger version) into the <textarea>
, the user clicks the image. However, the live preview doesn't show the image until the user adds additional input in the <textarea>
. Is it possible to update the live preview through jQuery?
Here's the code I'm using to insert the image:
$("img").click(function () {
var imgsrc = $(this).attr('src');
var content = $('textarea').val();
$('textarea').val(content + '<a href="' + imgsrc + '"><img src="' + imgsrc + '" width="50" height="50" /></a>');
});
I figured it out. If we bind the
focus
event in the MarkdownDeepEditor.js file, then set the focus to thetextarea
, the preview will update.Add the following after line 539 in MarkdownDeepEditor.js: (you should see the other BindEvents.)
In my html, I'll add the following code: