1

I am using JQuery Datatables (1.10) to render data. One of the cells contains the value "B&EE". The issues is this value does not render properly, as only "B" is rendering.

If I modify the value to "B & EE" or "B&EE S", both of those values render fine. Also, other special characters don't seem to have this problem either.

Does anyone know why the value "B&EE" is not rendering properly and what can be done to fix the issues?

Rob Breidecker
  • 604
  • 1
  • 7
  • 12
  • &EE is a html entity for the ⅇ character. Look at this post, might help you: http://stackoverflow.com/questions/11294107/how-can-i-send-the-ampersand-character-via-ajax – Stefan Jul 08 '15 at 18:18
  • Can you please give an example of your code or link to your page? `B&EE` shows correctly in the table, see [this JSFiddle](http://jsfiddle.net/uefhzyfL/). – Gyrocode.com Jul 08 '15 at 18:41
  • It turns out my issue is only with IE8. I did not see the problem in Chrome or IE11. To fix the problem in IE8, I have to html encode my data. – Rob Breidecker Jul 08 '15 at 20:43
  • 1
    Apparently, older browsers didn't require a semicolon, see [this answer](http://stackoverflow.com/a/18692507/3549014) so maybe `&EE` was treated as an entity. You can answer your own question if you want and accept your answer, this will close the question. – Gyrocode.com Jul 08 '15 at 20:53

3 Answers3

0

It turns out my issue is only with IE8. I did not see the problem in Chrome or IE11. To fix the problem in IE8, I have to html encode my data.

I did this something like this in my datatable to encode the data before rendering.

"columnDefs": [
    {
        "render": function ( data, type, row ) {
            return $('<div/>').text(data).html();
        },
        "targets": 3
    }
Rob Breidecker
  • 604
  • 1
  • 7
  • 12
0

It seems like HTML engine is trying to render it as an entity.For ampersand(&) Entity is &amp; ...For eg something like this

var str = "B & EE";
var res = str.replace("&", " &amp;");
Gkrish
  • 1,811
  • 1
  • 14
  • 18
-1

B&amp;amp;EE will give you what you're looking for.

KidBilly
  • 3,408
  • 1
  • 26
  • 40
  • This is not correct, HTML entities have format `entity_number;` or `&entity_name;` so `&EE` should not be treated by browsers as such. – Gyrocode.com Jul 08 '15 at 18:56