2012-07-02 7 views
6

アロハエディタのドキュメントには、「aloha-smart-content-changed」イベントのリッスンを聞くことができます。たとえば、使用している永続性メカニズムにデータを保存することができます。ここに私がしようとしているものの例があります:アロハ・エディタ "aloha-smart-content-changed"イベントを聞く?

<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> 

しかし、ハンドラは決して起動しません。アロハと一緒に仕事をしている方は、イベントを正しく聞く方法を知っていますか?

答えて

8

うわー、これに関する書類はかなり悪かったです。しかし、私はそれが働くようになったと思う。 Aloha.ready()メソッド内のイベントハンドラとAlohaオブジェクト自体をバインドするように見えます。

Aloha.ready(function() { 
     var $ = Aloha.jQuery; 
     $('.editable').aloha(); 

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

hereについて少し詳細情報を発見し、私はevent being boundの例を発見した場所です。

はまた

+1

パーフェクトを助けjsfiddle here

希望でこれをテストしました。ニースを見つける、アミン、ありがとう! – mjswensen

+0

実際のコンテンツをどのように入手するかについてのご意見はありますか? :/ – Populus

+0

@Populus Aloha.getActiveEditable()。getContents(); 'を試してください。 – mjswensen

関連する問題