Link to home
Start Free TrialLog in
Avatar of Yakup K
Yakup K

asked on

Jquery append method issue on the IE browser

var nestedtablesettings = {
    "iDisplayLength": 20,
    "bLengthChange": false,
    "bFilter": true,
    "bSort": true,
    "bInfo": false,
    "drawCallback" : function() {
        var appendDownloadLink = $("table table td .dataTables_filter");
        appendDownloadLink.each(function(i, e) {
            var label = $('label', e);
            $(e).html('<a class="export-circuits" href >Export circuits</a>').append(label);

            $(".export-circuits").on("click", function(e){
                circuit = $(this).closest('tr').prev('tr').children('td').eq(1).text();
                hpath = "exportCircuits?organisationID="+getbusinessID+"&interfaceName="+circuit;
                $(this).attr("href", hpath);
            });
        });
    }
};

Open in new window


I am trying to add an export link on the nested datatable.  When I try to see my result on Chrome and Firefox, it is working perfectly.

The result on chrome and Firefox
<div id="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0_filter" class="dataTables_filter"><a class="export-circuits" href="">Export circuits</a><label>Search:<input type="search" class="" placeholder="" aria-controls="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0"></label></div>

Open in new window


On the IE, it removed the data from label elements.
<div id="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0_filter" class="dataTables_filter"><a class="export-circuits" href="">Export circuits</a>
<label></label>
</div>

Open in new window


From my research, IE has got some issue with jquery append method.

Any helps would be highly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yakup K
Yakup K

ASKER

Thanks a lot Leakim. Excellent!.
Avatar of Yakup K

ASKER

Hi LeaKim,

That show the search box on the IE, but it removes the functionality of the search.  
With this implementation search does not work on any browsers now.

Do you have any ideas ?
what about :
var nestedtablesettings = {
    "iDisplayLength": 20,
    "bLengthChange": false,
    "bFilter": true,
    "bSort": true,
    "bInfo": false,
    "drawCallback" : function() {
        $("table table td .dataTables_filter").prepend('<a class="export-circuits" href >Export circuits</a>');
        $(".export-circuits").on("click", function(e){
            circuit = $(this).closest('tr').prev('tr').children('td').eq(1).text();
            hpath = "exportCircuits?organisationID="+getbusinessID+"&interfaceName="+circuit;
            $(this).attr("href", hpath);
        });
    }
};

Open in new window

Avatar of Yakup K

ASKER

Thanks for your help again. This solution is creating my previous issue again. When you append element like this, if you you click any links on the last level table, it duplicated the links because of datatable plugins.

<div id="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0_filter" class="dataTables_filter"><a class="export-circuits" href="">Export circuits</a><a class="export-circuits" href="">Export circuits</a><a class="export-circuits" href="">Export circuits</a><a class="export-circuits" href="">Export circuits</a><label>Search:<input type="search" class="" placeholder="" aria-controls="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0"></label></div>

Open in new window


That's why we tried like the following;

var label = $('label', e);
$(e).html('<a class="export-circuits" href >Export circuits</a>').append(label);

Open in new window


But, this solution removes the search box from the label.
it duplicated the links because of datatable plugins.

do you have a link or can reproduce that on jsfiddle ? I do'nt get it
Avatar of Yakup K

ASKER

jsfiddle

Thanks a lot for your help.

Please see the link on the jsfiddle. When you click on the inner table header, it duplicates the links.