{"id":93,"date":"2009-10-29T09:51:11","date_gmt":"2009-10-29T17:51:11","guid":{"rendered":"http:\/\/blog.portnumber53.com\/?p=93"},"modified":"2009-10-29T09:51:11","modified_gmt":"2009-10-29T17:51:11","slug":"weird-fck-loses-first-line-of-formatted-text-when-submitting","status":"publish","type":"post","link":"https:\/\/blog.portnumber53.com\/index.php\/2009\/10\/29\/weird-fck-loses-first-line-of-formatted-text-when-submitting\/","title":{"rendered":"Weird: FCK loses first line of formatted text when submitting"},"content":{"rendered":"<p>Last night (Oct, 28th), I was fixing a very weird problem where text edited using FCK, submitted via jQuery was losing the very first line when it was formatted (color, style) but not every single time&#8230; randomly it seemed.<\/p>\n<p>At first, I thought it would be something wrong with FCK editor and checked if there was an updated version. I was using 2.5.x on my site and 2.6.5 is current in the 2.x series (and 3.0.1 was just released, note: checking that for another website [http:\/\/thirdgenerationco.com]).<\/p>\n<p>Since I didn&#8217;t want to introduce new features (cause my client freaks out when I do without letting him know), I thought I&#8217;d give 2.6.5 a try. That did not solved my problem.<\/p>\n<p>My next logical step was checking how jQuery was encoding the text to preserve quotes and double quotes and making sure PHP was getting that right. Which both were.<\/p>\n<p>Next, I tried adding slashes and stripping them down, which also did not work.<\/p>\n<p>At this point, I thought about changing my Ajax approach&#8230;..\u00a0 but before that I&#8217;d though I&#8217;d give JSON a try.\u00a0 \ud83d\ude42<\/p>\n<p>So this is the changes I&#8217;ve made in my coding:<\/p>\n<p>Javascript side (My text is edited inside a dialog window (created using jQuery-UI) and then posted using Ajax, from the main window.<\/p>\n<blockquote>\n<pre>var new_text = $('#frame_frontpage').contents().find('#previewMyStoreMessageBoard').html();\n$(\"#previewFrontPageText\").html(new_text);\n$(\"#frontpage_text\").val(new_text);\n<span style=\"text-decoration: line-through;\"><span style=\"color: #ff0000;\">var str = $(\"#form_frontpage_text\").serialize();<\/span><\/span>\nvar This = this;\n<span style=\"color: #ff0000;\"><span style=\"text-decoration: line-through;\">$.post('\/member\/store_home_page\/ajax_save_frontpage_text', str,<\/span><\/span>\n<span style=\"color: #0000ff;\">$.post('\/member\/store_home_page\/ajax_save_frontpage_text', {frontpage_text: new_text},<\/span>\n  function(text) {\n    if (text == \"success\") {\n    alert(\"Store Description Text submitted successfully.\");\n    $(This).dialog('close');\n  } else {\n    alert(text);\n  }\n}\n);<\/pre>\n<\/blockquote>\n<p>Besides that I just added addslashes() and stripslashes() to preserve double quotes to\/from the database.<br \/>\nAnd it&#8217;s now working \ud83d\ude00<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last night (Oct, 28th), I was fixing a very weird problem where text edited using FCK, submitted via jQuery was losing the very first line when it was formatted (color, style) but not every single time&#8230; randomly it seemed. At first, I thought it would be something wrong with FCK&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/blog.portnumber53.com\/index.php\/2009\/10\/29\/weird-fck-loses-first-line-of-formatted-text-when-submitting\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[36,106,130,140,146,200,272,325,360],"class_list":["post-93","post","type-post","status-publish","format-standard","hentry","category-development","tag-addslashes","tag-developement","tag-encoding","tag-fckeditor","tag-formatted-text","tag-jquery","tag-php","tag-stripslashes","tag-weird"],"_links":{"self":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/comments?post=93"}],"version-history":[{"count":0,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/93\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/media?parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/categories?post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/tags?post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}