Listening to Aloha's editor aloha-smart-content-changed event?

According to Aloha editor’s docs, you can listen to the “aloha-smart-content-changed” event to get help, say, to save data in any save mechanism you use. Here is an example of what I'm trying to do:

<html> <head> <title>Aloha Event Testing</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script src="http://cdn.aloha-editor.org/current/lib/aloha.js" data-aloha-plugins="common/format, common/list, common/link, common/highlighteditables"></script> <link href="http://cdn.aloha-editor.org/current/css/aloha.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> Aloha.ready( function() { var $ = Aloha.jQuery; $('.editable').aloha(); }); $(document).ready(function() { $('.editable').bind('aloha-smart-content-changed', function() { console.log('Aloha smart event handled.'); }); }); </script> </head> <body> <div class="editable"></div> </body> </html> 

But the handler never fires. Does anyone who worked with Aloha know how to listen to the event?

+6
source share
1 answer

Wow, the documentation on this was pretty poor. But I think I did it. It looks like you are attaching event handlers inside the Aloha.ready () method to the Aloha object itself.

 Aloha.ready( function() { var $ = Aloha.jQuery; $('.editable').aloha(); Aloha.bind('aloha-smart-content-changed', function(event, editable) { console.log('Aloha smart event handled.'); }); }); 

Found a little more information about this here , and it was here that I found an example of a related event .

Also checked this in jsfiddle here

Hope that helps

+8
source

Source: https://habr.com/ru/post/919539/


All Articles