根据 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 合作过的人知道如何正确收听该事件吗?
哇,这方面的文档非常糟糕。但我想我已经成功了。看起来您将 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 http://aloha-editor.org/builds/development/alohaeditor-0.21.0-dev-SNAPSHOT-source-20120330-012607/doc/guides/source/events.textile这就是我找到一个例子的地方事件被绑定 https://github.com/alohaeditor/Aloha-Editor/issues/445.
也测试了这一点jsfiddle在这里 http://jsfiddle.net/rrn8x/3/
希望有帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)