Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

using onChange or OnKeyDown with CKEditor

Posted on 2010-08-17
7
3,081 Views
Last Modified: 2013-11-19
I'm trying to create a custom javascript function for CKEditor but am unable to find anything on where to place this function within the existing CKEditor script.

If I add my function to the main textarea it doesn't work, I think this is because that textarea gets replaced with the instance of CKEditor.

Has anyone had any luck getting a onChange event to fire a custom function in Javascript? os seen an example of how to do this?

Thanks
0
Comment
Question by:elliottbenzle
7 Comments
 
LVL 6

Expert Comment

by:TheQuietShadow
ID: 33455330
You will probably need to create an instance of the object in your header, then call it with the onchange event in the body.
You will also want to make sure that your onchange event is not being called except when you want it to occur.
0
 
LVL 6

Expert Comment

by:TheQuietShadow
ID: 33455413
You should also note that your code is excluding the last character (or keyboard action).
"hello" apears as "hell" but if you type "hello " and then hit backspace it apears as "hello " where is should display as "hello".
0
 
LVL 6

Accepted Solution

by:
TheQuietShadow earned 500 total points
ID: 33455464
try using "onkeyup" instead of "onkeydown"!
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 82

Expert Comment

by:leakim971
ID: 33455715
for info the textarea is hidden. It goal is to send on form submission the CKEditor code (equ of what you see on the screen)

You need to use the API : http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.event.html#on

someObject = CKEDITOR.instances.ID_OF_YOUR_TEXTAREA

someObject.on("change", function() {
     alert("Changed !");
});

Open in new window

0
 
LVL 4

Author Closing Comment

by:elliottbenzle
ID: 33455870
The onKeyUp was very helpful. Thank you.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33459040
I'm sorry but this is not the right answer for CKEditor :o(
0
 
LVL 2

Expert Comment

by:wpatterson82
ID: 35477398
ths is incorrect for CKEditor .. but works for a plain textfield
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question