find and replace with jQuery

find and replace with jQuery

berntebernte Posts: 6Questions: 0Answers: 0
edited April 2013 in General
hi guys.. i have a question

i have an datatable field with this content (for example)
[code]One | Two | Three | Four | Six | Seven[/code]
now i want to remove with jquery "Three |" with "nothing"

normally i do it with:
[code]$('td').html($('td').html().replace('Three | ', ''));[/code]

You can see a working demo here: http://jsfiddle.net/a8pBG/

but it doesn't work with datatables.

any ideas to realize this?

regards berni


edit:

or another solution i can use

i have only whitespaces between every word.
[code]One Two Four Six Seven[/code]

is it possible to add on column 3 a separator between all whitespaces?
(find " " and replace with " | ")

so my table looks like this
[code]One | Two | Four | Six | Seven[/code]

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    You need to use the fnUpdate API if you are going to modify the contents of the cell, in order that DataTables knows that you have made some changes. This is the same as the reason for the `append` FAQ: http://datatables.net/faqs#append .

    It is a bit of a pain at the moment using fnUpdate for this, but I'll be making the new API a lot more flexible in DataTables 1.10 for this kind of thing.

    Allan
This discussion has been closed.