I am using: jquery.dataTables.js from: https://datatables.net
I am trying to make each tr have a link, but some reason this is not working, I tried run in my console on chrome and works, someone can explain me why i can't insert this links in my element?
it is something related to the json data?
html:
<div class=" dashboard">
<div class="col-md-8 no-padding">
<div class="form-group col-md-4 no-padding">
<select class="form-control" id="sel1">
<option value="Filter by">Filter by country </option>
<option value="All">All</option>
<option value="China">China</option>
<option value="EUA">EUA</option>
<option value="Spain">Spain</option>
</select>
</div>
</div>
<br>
<br>
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>First name</th>
<th>Place</th>
</tr>
</thead>
</table>
jquery:
$(document).ready(function() {
var dt = $('#example').dataTable();
dt.fnDestroy();
});
$(document).ready(function() {
var url = 'http://www.json-generator.com/api/json/get/crcCiZXZfm?indent=2';
var table = $('#example').DataTable({
ajax: url,
columns: [{
data: 'name'
}, {
data: 'place'
}]
});
$('#sel1').change(function() {
if (this.value === "All") {
table
.columns(1)
.search('')
.draw();
} else {
table
.columns(1)
.search(this.value)
.draw();
}
});
});
$(document).ready(function() {
$('#example tbody tr').attr('onclick', "document.location = 'edit.html'");
});
jquery I want insert:
$('#example tbody tr').attr('onclick', "document.location = 'edit.html'");
jsfiddle but not with jquery above: http://jsfiddle.net/f7debwj2/