sType:html - Issue with \r \n ?

sType:html - Issue with \r \n ?

Christian BonatoChristian Bonato Posts: 18Questions: 0Answers: 0
edited July 2011 in General
Hi Allan,

Invisible chars in a html string passed to a row break everything.

Since I often need to put large chunks of html into aaData, would it be possible to have a function that pre-processes the html string and get rid of all invisible chars so that it remains human-readable ?


This breaks JQuery :

[code]
"


..."
[/code]


This does not :

[code]
"..."
[/code]

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    I don't quite understand I'm afraid. In what way does your code block "break jQuery"? Bare in mind that multi-line strings aren't really supported in Javascript - you can have \r and \n in a string sure, but you can't do something like this:

    [code]
    var a = "
    whatever
    ";
    [/code]

    Allan
  • Christian BonatoChristian Bonato Posts: 18Questions: 0Answers: 0
    Hi Allan,

    You're right about multi-line strings aren't really supported in Javascript.

    I inject a lot of HTML in my table's td's, so the html is really hard to wrok with without line breaks.

    I ended up creating a big php string var, with lone breaks for code readability, and then clean it before passing it in aaData with :

    [code]
    $str = str_replace(CHR(10),"",$str);
    $str = str_replace(CHR(13),"",$str);
    $str = str_replace(CHR(9),"",$str);
    [/code]
This discussion has been closed.