views:

199

answers:

4

I'm using the markitup! as a markdown editor (example).

Currently, I need to press the preview button (green tick) to display the preview panel.

I would like the preview to be displayed automatically - how can I achieve this?

A: 

This article shows how to select by title ('preview') in this case. You can then select the anchor tag ('a') with title preview and then click it.

Best of luck,

Dan

Daniel Elliott
+2  A: 

I have no experience with this editor but

$('a[title="Preview"]').trigger('mouseup');

called after the editor loads seems to do what you want.

Mark
+1 Works great thanks!
Tim Santeford
A: 

Mark's answer worked. For the sake of completeness, here's where I added his code:

<script type="text/javascript" >
$(document).ready(function()    {
    $('#markdown').markItUp(myMarkdownSettings);
    $('a[title="Preview"]').trigger('mouseup');
});
</script>
Alasdair
+1  A: 

Just in case anybody else is following the accepted answer and runs into problems:

$('a[title="Preview"]').trigger('mousedown');

worked for me (while 'mouseup' didn't). Maybe they changed the behaviour in the newest version of markItUp! (v1.1.7)?

Volker Rose