refactory-id / bootstrap-markdown

Bootstrap plugin for markdown editing
Apache License 2.0
1.99k stars 371 forks source link

Unclear on how to hide the markdown editor #94

Closed coderhs closed 8 years ago

coderhs commented 10 years ago

Hey there, I wish to make the markdown editor show/hidden on button click.

To make it visible i wrote the following code with in the click trigger

$("#article").markdown({autofocus:true,savable:false,iconlibrary:'fa'});

but when i try to use the $('#article').showEditor() toggle api. it gives the following error

TypeError: Object [object Object] has no method 'showEditor'.

lodev09 commented 10 years ago

You can't do this: $('#article').showEditor() since that would be a new fn extended from jquery. Anyway, you can add that in any event inside bootstrap-markdown. e.g:

$("#article").markdown({
    autofocus:true,
    savable:false,
    iconlibrary:'fa',
    onShow: function(e) {
        e.showEditor();
    }
});

Ofcourse the onShow event does that already, it's just a sample. Hope that helps

lodev09 commented 10 years ago

An update to this answer: If you really want to do this outside the definition, you can do it like this: $('#article').data('markdown').showEditor(); provided that you initialized $('#article').markdown( ... ) already.

coderhs commented 10 years ago

Thanks for the tip. Ya i have already initialized markdown it, let me try that.

niknokseyer commented 9 years ago

Thanks @lodev09. That's helpful.