Weird: FCK loses first line of formatted text when submitting

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… randomly it seemed.

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]).

Since I didn’t want to introduce new features (cause my client freaks out when I do without letting him know), I thought I’d give 2.6.5 a try. That did not solved my problem.

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.

Next, I tried adding slashes and stripping them down, which also did not work.

At this point, I thought about changing my Ajax approach…..  but before that I’d though I’d give JSON a try.  🙂

So this is the changes I’ve made in my coding:

Javascript side (My text is edited inside a dialog window (created using jQuery-UI) and then posted using Ajax, from the main window.

var new_text = $('#frame_frontpage').contents().find('#previewMyStoreMessageBoard').html();
$("#previewFrontPageText").html(new_text);
$("#frontpage_text").val(new_text);
var str = $("#form_frontpage_text").serialize();
var This = this;
$.post('/member/store_home_page/ajax_save_frontpage_text', str,
$.post('/member/store_home_page/ajax_save_frontpage_text', {frontpage_text: new_text},
  function(text) {
    if (text == "success") {
    alert("Store Description Text submitted successfully.");
    $(This).dialog('close');
  } else {
    alert(text);
  }
}
);

Besides that I just added addslashes() and stripslashes() to preserve double quotes to/from the database.
And it’s now working 😀

Tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • IGlr