Holt59 / datatable

Javascript Plugin for data tables creation
http://holt59.github.io/datatable/
MIT License
107 stars 42 forks source link

Text input filter failed with html tags inside <td></td> #19

Closed tinotk closed 8 years ago

tinotk commented 8 years ago

Consider the table below, the search function for text input filter works fine on the first <td></td>, but failed on the third <td></td>. If I striped all the html tags inside the third td leaving just the text, the search works fine. Please advise.

<tbody>
    <tr>
        <td><a href="xyz/abc/"><strong>Title A</strong></a>&nbsp;<span class="badge"><small>0</small></span>&nbsp;</td>
        <td><span class="label label-info">Cat A</span></td>
        <td><small><a href="search/one+two+three">One Two Three</a></small></td>
    </tr>
    <tr>
        <td><a href="xyz/abc/"><strong>Title B</strong></a>&nbsp;<span class="badge"><small>0</small></span>&nbsp;</td>
        <td><span class="label label-info">Cat A</span></td>
        <td><small><a href="search/one+two+three">One Two Three</a></small></td>
    </tr>
    <tr>
        <td><a href="xyz/abc/"><strong>Title C</strong></a>&nbsp;<span class="badge"><small>0</small></span>&nbsp;</td>
        <td><span class="label label-info">Cat A</span></td>
        <td><small><a href="search/four+five+six">Four Five Six</a></small></td>
    </tr>
    <tr>
        <td><a href="xyz/abc/"><strong>Title D</strong></a>&nbsp;<span class="badge"><small>0</small></span>&nbsp;</td>
        <td><span class="label label-info">Cat C</span></td>
        <td><small><a href="search/one+two+three">One Two Three</a></small></td>
    </tr>
    <tr>
        <td><a href="xyz/abc/"><strong>Title E</strong></a>&nbsp;<span class="badge"><small>0</small></span>&nbsp;</td>
        <td><span class="label label-info">Cat B</span></td>
        <td><small><a href="search/asdf">Nine Ten</a></small></td>
    </tr>
</tbody>
Holt59 commented 8 years ago

Should be fixed by 8f4dbf78f64b99778191be6d216d0d0a1b3da448.

tinotk commented 8 years ago

I discovered a quick and dirty workaround was to put an &nbsp; before closing the </td>. Thanks for adding the strip tags function. That fixes the issue.

Holt59 commented 8 years ago

The &nbsp; tricks work but it will make the search a bit weird since the tags will also be matched (e.g. span will match every line in your case).

I am closing this if this is ok for you, feel free to reopen if it does not work as intended.