DataTables logo DataTables

via Ad Packs
sDom string replacement error
  • brennanbrennan
    Posts: 1
    Assuming you are looking at jquery.dataTables.js (not the min version) line 1037 begins the description of the sDom varriable. It describes that 'H' and 'F' are used to insert jQueryUI themes.

    Line 2839 is where the actual code is executed to perform the string replacement
    2839	var sDom = oSettings.sDom.replace( "H", "fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix" );
    2840 sDom = sDom.replace( "F", "fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix" );

    This is all fine and dandy except when you add a div in sDom with a class name that has a capital H or F in it such as...
    $(document).ready(function() {
    	var oTable = $('#myTable').dataTable({
    		"sDom": '<"myHeader">t<"myFooter">'
    	});
    }
    

    What happens is the string replacement will produce
    <div class="myfg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfixeader"></div>
    <table...></table>
    <div class="myfg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfixooter"></div>
    

    When what we really want it to do is
    <div class="myHeader"></div>
    <table...></table>
    <div class="myFooter"></div>
    

    The string replacement line needs to be more intelligent an not do a replacement on characters that are inside quotes.
  • allanallan
    Posts: 15,505
    Good point! Thank you for pointing that out. I'll put a fix for this into the next version :-)

    Regards,
    Allan
This discussion has been closed.
← All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion