I am looking into adding a listener to the CKEditor 4 text area in javascript. What I need to do is when I click on the text the user entered I need to be able to select a range base on the cursor positon within. I have been trying everything in the forum to add the handler to the onclick event, with no success. If anyone has an example of how to do this it would be appreciated. Also if the example includes a generic "MyElement" or the like, could you please explain how to get the text area element?
I have tried the following:
The Markup:---------------------------------------- <CKEditor:CKEditorControl ID="CKEditor1" BasePath="~/ckeditor" runat="server" onblur="CKEditor1LostFocus();"></CKEditor:CKEditorControl> ServerSide:---------------------------------------- Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CKEditor1.CKEditorInstanceEventHandler = New System.Collections.Generic.List(Of Object) CKEditor1.CKEditorInstanceEventHandler.Add(New Object() {"instanceReady", "function (evt) { instanceReady(); }"}) CKEditor1.CKEditorInstanceEventHandler.Add(New Object() {"blur", "function (evt) { CKEditor1LostFocus(evt);}"}) CKEditor1.CKEditorInstanceEventHandler.Add(New Object() {"click", "return CKEditor1Click();"}) CKEditor1.CKEditorInstanceEventHandler.Add(New Object() {"dblclick", "function (evt) { return CKEditor1DblClick();}"}) CKEditor1.CKEditorInstanceEventHandler.Add(New Object() {"keyup", "function (evt) { return CKEditor1KeyUp();}"}) End Sub ClientSide:--------------------------------------------------- function instanceReady() { var element = CKEDITOR.document.getById('CKEditor1'); element.on('click', function (ev) { alert("Click"); }); }
Thanks
Click events in Form Fields
Hi,
we use this Javascript Code to Handle the click event in Formular Items (textareas, select items...) in dialogs of the CKEditor because we got Problems with the focus, so we did it manually.
http://ckeditor.com/forums/CKEditor/SOLVED-Register-Clickhandler-on-every-dialog-plugin
Maybe you can use parts of this code to to something similiar for your Case? If not, do you receive any Exceptions or what seems to be the trouble?
Greetings
I tried your solution and was
I tried your solution and was able to get an alert when a dialog is shown, but I need it on the main text area. I am not sure where to look for the main text area element. Unfortunately, this solution does not apply to this text area.