Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

using onChange or OnKeyDown with CKEditor

Posted on 2010-08-17
7
Medium Priority
?
3,122 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

661 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