Stripping HTML tags out to leave text only.

Stripping HTML tags out to leave text only.

PJ03029174PJ03029174 Posts: 4Questions: 1Answers: 0

Hi, I have a personal localhost website and have HTML stored in one of my fields from the summernote editor. Is there anything already available to strip HTML tags out and render the field as Text without the Tags in the datatable?

I've started using the render ellipsis plugin which is cool for this field but the tooltip is pretty hard to read with the html tags present (as is the data in this particular column on the datatable)

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @PJ03029174 ,

    There's not a renderer for that, but something like this works 99% of the time - see "Tiger Nixon" in the HTML.

    Cheers,

    Colin

  • PJ03029174PJ03029174 Posts: 4Questions: 1Answers: 0

    Thanks Colin, that looks great. I'm using the

    "render": $.fn.dataTable.render.ellipsis( 50,true,false )

    code and have put

    shortened = shortened.replace( /<.*?>/g, '' );

    into the fn.dataTable.render.ellipsis() function.

    Do you happen to know if I can use this code on the tooltip output? the tags are successfully removed from the datatable but when I hover over an ellipse value the tooltip still displays the tags.

    Thanks a lot for the help. Pete

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @PJ03029174 .

    Would you be able to change my example in that last post to show what you're got and done so far - it would help to understand what you have,

    Cheers,

    Colin

  • PJ03029174PJ03029174 Posts: 4Questions: 1Answers: 0

    Hi Colin

    I cloned your example and updated with my code, here

    Thanks so much for the help!

  • kthorngrenkthorngren Posts: 20,299Questions: 26Answers: 4,769
    Answer ✓

    Is this what you are looking for?
    http://live.datatables.net/wolojoza/1/edit

    Kevin

  • PJ03029174PJ03029174 Posts: 4Questions: 1Answers: 0
    edited May 2019

    That worked a treat, thank you Kevin

This discussion has been closed.