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.
ChromeJavaScriptjQueryInternet Explorer (IE)Firefox

Avatar of undefined
Last Comment
Yakup K

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
leakim971

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Yakup K

ASKER
Thanks a lot Leakim. Excellent!.
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 ?
leakim971

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

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
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.
leakim971

it duplicated the links because of datatable plugins.

do you have a link or can reproduce that on jsfiddle ? I do'nt get it
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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.