refactory-id / bootstrap-markdown

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

Allows clean async preview implementation with minimal changes to the code base. #300

Closed ghord closed 7 years ago

ghord commented 7 years ago

Sample async implementation for preview event:

$("#text-editor").markdown({
    onPreview: function (e, previewContainer) {
        $.ajax({ method: "POST", url: "/news/preview", data: { text: e.getContent() } })
            .then(function (result) {
                previewContainer.html(result);
            })

            //return placeholder string. It will be replaced after successfull ajax call
            return "Loading preview...";
   }
})
lodev09 commented 7 years ago

thanks @ghord