Opened 11 years ago
Closed 11 years ago
#11301 closed Bug (invalid)
Blur event doesn't fire the first time that it should
Reported by: | Jeremie Wood | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | |
Keywords: | Cc: |
Description
See demonstration page here: http://terrafirma.org/ckeditor_test.html
When automatic inline editing is turned off and an inline editor instance is created manually, the editor's blur event does not fire the first time you click outside the editor.
What I expect to happen:
- Click the edit button to edit the text
- Click outside the editor area when done editing
- The editor's blur event should fire
However, the first time you click outside the editor area, nothing happens. You have to click on the editable text and then click outside a second time before the blur event fires.
Here's the code that I'm using:
(function($) { $(function() { CKEDITOR.disableAutoInline = true; $('#edit_button').click(function(e) { var editable = $('#editable_text'); var editor = CKEDITOR.instances[editable.attr('id')]; if (typeof(editor) === "undefined") { editable.attr('contenteditable', true); CKEDITOR.inline(editable.prop('id')).on('blur', function() { saveData(editable, true); }); } editable.focus(); }); }); function saveData(element, async) { var dom_obj = $(element); var editor = CKEDITOR.instances[dom_obj.attr("id")]; if (typeof(editor) !== "undefined") { editor.destroy(); } dom_obj.attr('contenteditable', false); alert('CKEditor blur event fired'); } }(jQuery));
Nevermind, I found a solution. Instead of calling focus on the DOM object, if I pass startupFocus: true as a parameter then CKEditor will start focused and correctly call blur when clicking elsewhere on the page.