SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2012
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting and using data from CKEditor?

    Hey guys, i'm trying to use CKEditor for people to enter text in and ill use the text to put it in a database and show them what they typed. How would i do this with Jquery? I know that using the .getData() gets you the text, but i want to take that text and append it to a <p> tag so that the user can see what they typed. Also, how could it be made to update on the .keyup function?

    I have the code to make it show up in the <p> tag:
    Code:
     
    var editor = CKEDITOR.replace('editor');
    var editor_data = editor.getData();
    
     $('p.new-content').text(editor_data);
    but i can't seem to make it update at all. What could be a good solution for this?

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,890
    Mentioned
    211 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    Could you post a link to a demo page that includes the CKEditor?
    That way I can play around with it and try and help you solve your problem.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2012
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here's the demo link: http://ckeditor.com/demo

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,890
    Mentioned
    211 Post(s)
    Tagged
    12 Thread(s)
    Ok, thanks.

    It turns out that there's no default event fired whenever something changes in CKEditor, but it's possible to extend the CKEditor API and add this functionality.
    Here's a blog post with a working demo that does what you want: http://alfonsoml.blogspot.com.es/201...-ckeditor.html

    Hope that helps.
    Let me know if you run into any trouble.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2012
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    perfect! thank you!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •