Error in IE when setting data
//Does not matter what one is used, both cause error
editor.setData('');
$('#roomId .MessageImput').val('');
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="Scripts/jquery-1.4.4.js" type="text/javascript"></script>
<script src="Scripts/CKEditor/ckeditor.js" type="text/javascript"></script>
<script src="Scripts/CKEditor/adapters/jquery.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
$('#roomId .MessageImput').ckeditor();
var editor = $('#roomId .MessageImput').ckeditorGet();
editor.on('key', function (event) {
if (event.data.keyCode == 13) {
processMessage();
}
});
});
function processMessage() {
$('#roomId .RoomBody').append($('<div></div>').html($('#roomId .MessageImput').val()));
var editor = $('#roomId .MessageImput').ckeditorGet();
//Does not matter what one is used, both cause error
editor.setData('');
$('#roomId .MessageImput').val('');
editor.focus();
}
</script>
<div id="ChatRooms">
<fieldset id="roomId">
<legend>Room Name</legend>
<div class="RoomBody">
</div>
<textarea class="MessageImput"></textarea>
<button class="SubmitMessageButton">
Submit
</button>
</fieldset>
</div>
</body>
</html>
Re: Error in IE when setting data
The event needs to be canceled to prevent it from trying to process the enter key with:
The updated code looks like:
editor.on('key', function (event) { if (event.data.keyCode == 13) { processMessage(); //Need to stop it from trying to process the enter key event.cancel(); } });