根据 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/