{"id":7889,"date":"2012-07-17T17:10:44","date_gmt":"2012-07-17T10:10:44","guid":{"rendered":"http:\/\/tom.ji42.com\/?p=7889"},"modified":"2012-07-17T17:10:44","modified_gmt":"2012-07-17T10:10:44","slug":"edit-in-place-with-ckeditor","status":"publish","type":"post","link":"https:\/\/tom.tomwork.net\/?p=7889","title":{"rendered":"Edit In Place with CKEditor"},"content":{"rendered":"<p>Setup<\/p>\n<p>1. Include JQuery 1.3.2 or newer to &lt;head&gt;. (1.7.2 is recommended)<\/p>\n<p>&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;https:\/\/ajax.googleapis.com\/ajax\/<\/p>\n<p>libs\/jquery\/1.7.2\/jquery.min.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>2. Include CKEditor after JQuery. (don&#8217;t forget to check file path)<\/p>\n<p>&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;ck\/ckeditor.js&#8221;&gt;&lt;\/script&gt; &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;ck\/adapters\/jquery.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>3. Include ck-in-place.js after CKEditor. (don&#8217;t forget to check file path)<\/p>\n<p>&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;ck-in-place.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p><!--more-->Note: data will POST to hander in var $_POST[&#8216;content&#8217;]. (you can define handler url with data-handler attribute. See example for more info.)<\/p>\n<p>Quick Example<\/p>\n<p>add to div element.<\/p>\n<ul>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example1-showcase\">Example 1<\/a><\/li>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example1-html\">HTML<\/a><\/li>\n<\/ul>\n<div id=\"content_9429177\">\n<p>Double Click to Edit<\/p>\n<p>You may edit this content, but it cannot save.<br \/>\nYou need to add data-handler to handle the change. See next example for more info.<\/p>\n<\/div>\n<p>Quick Example with Data Handler<\/p>\n<p>add and data-handler=&#8221;handler.php&#8221; to div element.<\/p>\n<ul>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example2-showcase\">Example 2<\/a><\/li>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example2-html\">HTML<\/a><\/li>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example2-handler\">handler.php<\/a><\/li>\n<\/ul>\n<div id=\"content_22033143\" data-handler=\"handler.php\">\n<p>Double Click to Edit<\/p>\n<p>You may edit this content then save.<br \/>\nhandler.php will store change to cookie. Refresh this page and see it yourself!<\/p>\n<p>In real use you may edit handler.php to store content in DB or do whatever you want.<\/p>\n<p>p.s. cookie will expire in 1 minute after save.<\/p>\n<\/div>\n<p>Simple Tools<\/p>\n<p>add to div element.<\/p>\n<ul>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example3-showcase\">Example 3<\/a><\/li>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example3-html\">HTML<\/a><\/li>\n<\/ul>\n<div id=\"content_87072810\">\n<p>Double Click to Edit<\/p>\n<p>Add simple class to show only simple tools.<\/p>\n<p>You may edit this content, but it cannot save.<\/p>\n<\/div>\n<p>All Tools<\/p>\n<p>add to div element.<\/p>\n<ul>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example4-showcase\">Example 4<\/a><\/li>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example4-html\">HTML<\/a><\/li>\n<\/ul>\n<div id=\"content_47377519\">\n<p>Double Click to Edit<\/p>\n<p>Add full class to show all tools.<\/p>\n<p>You may edit this content, but it cannot save.<\/p>\n<\/div>\n<p>Advance Usage<\/p>\n<p>You may custom it yourself.<\/p>\n<ul>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example5-showcase\">Example 5<\/a><\/li>\n<li><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/#example5-html\">HTML<\/a><\/li>\n<\/ul>\n<div id=\"EditMe\">Click to edit<br \/>\nYou may edit this content, but it cannot save<\/div>\n<p>Download<\/p>\n<p><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/ck-in-place.js\">ck-in-place.js (3.7 KB)<\/a><br \/>\n<a href=\"http:\/\/ckeditor.com\/download\">CKEditor (go to ckeditor.com\/download)<\/a><\/p>\n<p>Or download demo (this page) and see how it work.<\/p>\n<p><a href=\"http:\/\/www.earthchie.com\/sandbox\/ckinplace\/ckinplace.zip\">Demo (1.3 MB)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setup 1. Include JQuery 1.3.2 or newer to &lt;head&gt;. (1.7.2 is recommended) &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;https:\/\/ajax.googleapis.com\/ajax\/ libs\/jquery\/1.7.2\/jquery.min.js&#8221;&gt;&lt;\/script&gt; 2. Include CKEditor after JQuery. (don&#8217;t forget to check file path) &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;ck\/ckeditor.js&#8221;&gt;&lt;\/script&gt; &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;ck\/adapters\/jquery.js&#8221;&gt;&lt;\/script&gt; 3. Include ck-in-place.js after CKEditor. (don&#8217;t forget to check file path) &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;ck-in-place.js&#8221;&gt;&lt;\/script&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-7889","post","type-post","status-publish","format-standard","hentry","category-13"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6cOVM-23f","_links":{"self":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/7889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7889"}],"version-history":[{"count":0,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/7889\/revisions"}],"wp:attachment":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}