问题描述
Accoriding to the Aloha Editor docs可以听取aloha-smart-content-changed事件的帮助,例如,将数据保存到您正在使用的任何持久性机制。以下是我想要做的一个例子:
Accoriding to the Aloha Editor docs you can listen for the "aloha-smart-content-changed" event for help in, say, saving the data to whatever persistence mechanism you are using. Here is an example of what I am trying to do:
<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合作的人都知道如何正确听取这个事件?
But the handler never fires. Would anyone that has worked with Aloha know how to properly listen for the event?
推荐答案
哇,这个文件很差。但我想我得到了工作。看起来你将事件处理程序绑定在Aloha.ready()方法和Aloha对象本身之内。
Wow, the documenation on this was quite poor. But i think i got it to work. It looks like you bind the event handlers inside the Aloha.ready() method and to the Aloha object itself.
Aloha.ready( function() {
var $ = Aloha.jQuery;
$('.editable').aloha();
Aloha.bind('aloha-smart-content-changed', function(event, editable) {
console.log('Aloha smart event handled.');
});
});
找到一些关于它的更多信息,这是我发现一个。
Found a little bit more info about it here and this is where i found an example of an event being bound.
还在
Also tested this in jsfiddle here
希望有助于
这篇关于聆听Aloha编辑“aloha-smart-content-changed”事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!