Rss Feed
Tweeter button
Facebook button
Technorati button
Reddit button
Myspace button
Linkedin button
Webonews button
Delicious button
Digg button
Flickr button
Stumbleupon button
Newsvine button

Article written

  • on 20.06.2010
  • at 11:02 PM
  • by david4ie

Ckeditor Edit-In-Place jQuery Plugin.

Jun20

This jQuery Plugin allows you to add edit in place functionality to you web site but unlike most edit-in place plugins CKeip uses ckeditor.

Demo

How it works ?

When ckeip is called it creates a hidden CKeditor instance on the page, when the div you wish to make editable is double clicked the div will transform into a CKeditor instance.

How to use ?

Firstly before including ckeip make sure to have included ckeditor and the jquery adapter like below.

<script type=”text/javascript” src=”ckeditor/ckeditor.js”></script>
<script type=”text/javascript” src=”ckeditor/adapters/jquery.js”></script>

Using ckeip is very easy and requires just one function call.

$('#my_div_1').ckeip({

e_url: 'test.php'

)};

e_url is the only required settings and should the location of the server-side file which handles the data.

the plugin uses a POST request to send the data. The ckeditor html is sent in in a from field called content

If you require additional data to be sent to the server side code you can do the following :

$('#my_div').ckeip({
e_url: 'test.php',

data: {
example_var : 'example_value',
example_var2 : 'example_value2'
}

)};

you can then access these vars on your server side page using the following (in PHP) :

$_POST['data']['example_var'];

Options

e_hover_color – The color to change the editable div to on hover.
e_height – The height of ckeditor.
e_width – The width if ckeditor.
ckeditor_config     – This is the config options for ckeditor use like (see ckeditor docs for more info) :

ckeditor_config : {

toolbar:
[
['Source','-','Preview','-'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
['SelectAll','RemoveFormat'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],

'/',
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize', 'ShowBlocks','-'],[ 'UIColor' ]

]
}

data – See above.

Callback Function

you can hav a callback function like below. The param response is the data sent back by the server side page.

$('#my_div').ckeip({
e_url: 'test.php',
e_width:100,
e_height:100,
e_hover_color:'#333',

function (response) {
alert(response);
}

);

Download

Demo



Posts You May Like

Simple jQuery Scroll To Top Solution.
An Unobtrusive jQuery Login Box
Feature Rich jQuery Slide Out Info Bar
Jquery Expanding Textbox – Like facebook
The Easiest jQuery Tooltip
  • If you want to integrate ckeditor + ckfinder add these lines of code to ckeip.js at line (28)
    ___________________________________________________
    var editor = $('#ckeip_e_' + u_id + '').ckeditorGet();

    CKFinder.setupCKEditor(editor, '/ckfinder/');
    ___________________________________________________
    Now all instances will include ckfinder by default
  • Nicolas Franz
    Hi Dave! I wanna say thanks for the PIMG jQuery Plugin. But at the same time I wanna ask you something. I'm trying to apply the jQuery PIMG plugin to a WP theme that uses timthumb.php.
    The problem is that it doesn't work because all the image URLs when usin TimThumb becomes something like this:

    <img alt="alt text" class="pimg" src="http://localhost/wordpress/wp-content/themes/TheTheme/thumb.php?src=http://localhost/wordpress/wp-content/uploads/image1.jpg&amp;w=175&amp;zc=1&amp;q=80&amp;bid=1">

    So, as you could imagine, this don't allows the jQuery PIMG plugin to load the correct URL, and there's a POP-UP at IE6-7-8 that shows the error message.

    What do you think I can do to integrate the TimThumb with the PIMG plugin? Or well, do you of any plugin that automatically generate a Tooltip to open the original-size image of a thumbnail?

    Thanks again for such a great plugin!
  • someone
    Thanks! This helped me a lot!
    2 suggestions:
    - If you want to define default options for the ckeditor settings and merge them with custom settings change
    var settings = $.extend({}, defaults, options);
    to
    var settings = $.extend(true, defaults, options);

    - I customized the plugin for my purposes. As a result I came into a fight with ckeditor (errormessages like "The instance ... already exist..."). The classic js way for instantiating ckeditor seems to works better:
    if ( CKEDITOR.instances['ckeip_e_' + u_id + ''] ) {
    CKEDITOR.instances['ckeip_e_' + u_id + ''].destroy();
    };
    $('#ckeip_e_' + u_id + '').val(content2edit);
    editor = CKEDITOR.replace( 'ckeip_e_' + u_id + '', settings.ckeditor_config);
    CKEDITOR.on('instanceReady',function( evt )
    {
    $("#editbox").show();
    });

    ...instead of:
    $('#ckeip_e_' + u_id + '').ckeditor(settings.ckeditor_config);
    var settings = $.extend(true, defaults, options);

    - I customized your code for my purposes. As a result I came into a fight with ckeditor (errormessages like "The instance ... already exist..."). The classic js way for instantiating ckeditor seems to works better:
    if ( CKEDITOR.instances['ckeip_e_' + u_id + ''] ) {
    CKEDITOR.instances['ckeip_e_' + u_id + ''].destroy();
    };
    $('ckeip_e_' + u_id + '').val(content2edit);
    editor = CKEDITOR.replace( 'ckeip_e_' + u_id + '', settings.ckeditor_config);

    CKEDITOR.on('instanceReady',function( evt )
    {
    $("#editbox").show();
    });

    ...instead of...
    $('#ckeip_e_' + u_id + '').ckeditor(settings.ckeditor_config);
  • Ajaxylicious
    great plugin, but it looks like the data object isn't being parsed and put into an array. Running the demo straight outta the box, the data element returns an object instead of an array. It works on this demo, but the downloaded version causes the problem. Could you post the cause of this and a fix to it?
blog comments powered by Disqus

Dave Earley's Blog | jQuery | PHP | CSS | MySQL | Web Design is powered by WordPress
developed by Dariusz Siedlecki and brought to you by FreebiesDock.com