Why can’t i use bootstrap editable table in this way?
<table id="addElements" data-height="299">
<thead>
<tr>
<th data-field="id" data-align="right">Item ID</th>
<th data-field="element" data-align="center">Element</th>
<th data-field="weight" data-align="">Težina</th>
<th data-field="default_thickness" data-align="">Debljina</th>
</tr>
</thead>
</table>
//put data in js variable and fill the table
var elementData = [{
"id": "1",
"element": "c",
"weight": "20",
"default_thickness": "6"
}, {
"id": "2",
"element": "k",
"weight": "21",
"default_thickness": "2"
}, {
"id": "3",
"element": "p",
"weight": "18",
"default_thickness": "2"
}];
$(function () {
$('#addElements').bootstrapTable({
data: elementData
});
})
$.fn.editable.defaults.mode = 'inline';
$('td').editable({
url: '/post',
type: 'text',
pk: 1,
name: 'parket',
title: 'Enter username'
});
In this fiddle
https://jsfiddle.net/aleksacavic/03agu1ex/1/
it works, when clicked, table cells are in edit mode. But identical code on my site is not working? What am i missing? As i can see, on my side, when clicked, cells are not allowed to change class, only table thread gets highlighted, additional element (input field) not being created.
Thanks
2
Answers
You missed the ready function, due to this jquery is not able to bind the data.
try and add delay on load, should fix it: