Basic event triggering

This commit is contained in:
adi 2016-02-12 11:47:23 +01:00
parent 292d5fddee
commit cab13adb00
2 changed files with 29 additions and 0 deletions

View file

@ -29,6 +29,7 @@ Template is highly customizable, so you can easily use i.e. Bootstrap to layout
* [Customization](#customization)
* [Settings](#settings)
* [Widget's template](#widgets-template)
* [JS event handlers](#js-event-handlers)
* [Dependencies](#dependencies)
* [Changelog](#changelog)
* [License](#license)
@ -228,6 +229,24 @@ When you want to use Bootstrap 3 and side-by-side panes (as in preview image abo
</div>
```
## JS event handlers
Each markdownx jQuery object triggers two basic events:
* 'markdownx.init'
* 'markdownx.update' also returns 'response' variable containing markdownified text
```js
$('.markdownx').on('markdownx.init', function() {
console.log("INIT");
});
$('.markdownx').on('markdownx.update', function(e, response) {
console.log("UPDATE" + response);
});
```
# Dependencies
* Markdown
@ -237,6 +256,12 @@ When you want to use Bootstrap 3 and side-by-side panes (as in preview image abo
# Changelog
###### v1.4
* Added JS (jQuery) events
* Custom upload url path
* Fix when subclassing MarkdownxWidget
###### v1.3
* Added Markdown extension configuration setting

View file

@ -21,6 +21,7 @@
success: function(response) {
markdownxPreview.html(response);
updateHeight();
markdownx.trigger('markdownx.update', [response]);
},
error: function(response) {
@ -157,6 +158,7 @@
// Init
var markdownx = $(this);
var markdownxEditor = $(this).find('.markdownx-editor');
var markdownxPreview = $(this).find('.markdownx-preview');
@ -169,6 +171,8 @@
markdownxEditor.on('dragleave.markdownx', onDragLeaveEvent);
markdownxEditor.on('drop.markdownx', onDropEvent);
markdownx.trigger('markdownx.init');
updateHeight();
markdownify();
});