Solved

using onChange or OnKeyDown with CKEditor

Posted on 2010-08-17
7
3,088 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
[X]
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
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
Industry Leaders: 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!

 
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

Suggested Solutions

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to dynamically set the form action using jQuery.

740 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