From d9d739661259106aa606227a819b12026b4e6b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Liagre?= Date: Tue, 22 Dec 2015 11:30:45 +0100 Subject: [PATCH] Add jQuery validation example to the documentation --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index bc6c1ef..8a0983f 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,24 @@ simplemde.isSideBySideActive(); // returns boolean simplemde.isFullscreenActive(); // returns boolean simplemde.clearAutosavedValue(); // no returned value ``` +## jQuery validation +To mimic the jQuery validation on the editor, you can use the following code. + +```js + editor.codemirror.on("change", function() { + var element = $(editor.element); + $(element).val(editor.value()); + $(element).trigger('keyup'); + }); + + editor.codemirror.on("focus", function() { + $(editor.element).trigger('focus'); + }); + + editor.codemirror.on("blur", function() { + $(editor.element).trigger('blur'); + }); +``` ## How it works SimpleMDE is an improvement of [lepture's Editor project](https://github.com/lepture/editor) and includes a great many number of changes. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fortawesome.github.io/Font-Awesome/).