6

Aloha Editor docs によると、「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>

しかし、ハンドラーは決して発火しません。アロハと一緒に仕事をしたことがある人は、イベントを正しく聞く方法を知っていますか?

4

1 に答える 1

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.');
        });        
});

ここでそれについてもう少し情報を見つけました。これは、バインドされているイベントの例を見つけた場所です。

こちらのjsfiddleでもこれをテストしました

それが役立つことを願っています

于 2012-07-03T00:54:18.987 に答える