Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using onChange or OnKeyDown with CKEditor

Posted on 2010-08-17
7
Medium Priority
?
3,145 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 2000 total points
ID: 33455464
try using "onkeyup" instead of "onkeydown"!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

972 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