javascript - 收听 Aloha Editor "aloha-smart-content-changed"事件?

标签 javascript events aloha-editor

根据 Aloha Editor 文档,您可以监听“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>

但是处理程序永远不会触发。任何与 Aloha 合作过的人都知道如何正确地监听事件吗?

最佳答案

哇,这方面的文档很差。但我想我得到它的工作。看起来您将事件处理程序绑定(bind)到 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 的例子.

还在 jsfiddle here 中对此进行了测试

希望对你有帮助

关于javascript - 收听 Aloha Editor "aloha-smart-content-changed"事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11302385/

相关文章:

php - 无法获取 AJAX 表单来提交 MySQL 数据

javascript - 检查 Opera 中附加的 DOM 事件

vb.net - 防止在自定义文本框中触发验证/验证事件 - vb.net

javascript - 适用于桌面和移动设备的 jQuery 事件

javascript - 阿罗哈编辑器 : Add new styles to the toolbar and content

javascript - Aloha 编辑器不适用于 Opera,有时也不适用于 Chrome

php - 阿罗哈编辑器 : Inserting images/pictures

javascript - jQuery .append 不适用于 $(document).ready

javascript - 下面的语句在js中起什么作用

javascript - django找不到静态文件