asked on
var settings = {
"iDisplayLength": 20,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": false,
"drawCallback" : function() {
var appendDownloadLink = $("table table td .dataTables_filter label");
appendDownloadLink.each(function(i, e) {
$(e).before('<a class="take" href>Export departments</a>');
});
$(".take").on("click", function(e){
console.log("export links");
e.preventDefault();
circuit = $(this).closest('tr').prev('tr').children('td').eq(1).text();
console.log(circuit);
hpath = "exportCircuits?organisationID="+"hello"+"&interfaceName="+circuit;
console.log(hpath);
$(this).attr("href", hpath);
});
}
};
var table = new nestedTables.TableHierarchy("example", dataInJson, settings);
table.initializeTableHierarchy();
var settings = {
"iDisplayLength": 20,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": false,
"drawCallback" : function() {
var appendDownloadLink = $("table table td .dataTables_filter label");
appendDownloadLink.each(function(i, e) {
$(e).before('<a class="take" href>Export departments</a>').on("click", function(e){
console.log("export links");
e.preventDefault();
circuit = $(this).closest('tr').prev('tr').children('td').eq(1).text();
console.log(circuit);
hpath = "exportCircuits?organisationID="+"hello"+"&interfaceName="+circuit;
console.log(hpath);
$(this).attr("href", hpath);
});;
});
}
};
var table = new nestedTables.TableHierarchy("example", dataInJson, settings);
table.initializeTableHierarchy();
ASKER
ASKER
var appendDownloadLink = $("table table td .dataTables_filter");
appendDownloadLink.each(function(i, e) {
var label = $('label', e);
$(e).html('<a class="export-circuits" href target="_blank">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;
console.log(hpath);
$(this).attr("href", hpath);
});
});
}
ASKER
ASKER
ASKER
var appendDownloadLink = $("table table td .dataTables_filter");
appendDownloadLink.each(function(i, e) {
var label = $('label', e);
$(e).html('<a class="take" href>Export departments</a>').append(label);
});
<label>Search:<input type="search" class="" placeholder="" aria-controls="nested-datatable-covertab_0_row_1_tab_0_row_0_tab_0"></label>
On the IE11 it removes the content of the label for some reasons.<label></label>
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
$(e).before('<a class="take" href>Export departments</a>');
And that's called each time you do a redraw, so after you've ran it once, the content includes the link. The next time you run it, you're adding a link before the existing content (which now includes the link that was drawn the first time).
It might be easier to change your HTML so you have an empty DIV (div class="links" for example) that you can write the links to, and then you can just do:
Open in new window
Now each time you do a redraw, you're just setting the HTML of your .links container.