Getting error "$.fn.dataTable.Editor is not a constructor" while using inline editor
Getting error "$.fn.dataTable.Editor is not a constructor" while using inline editor
Sand
Posts: 6Questions: 0Answers: 0
My code is as follows:
$(function() {
$.ajax({
type: "GET",
url:"/textbook/list",
dataType: "json",
....... # code for listing text books
Book.BookList();
});
var Book = {
'init' : function() {
},
'BookList' : function() {
..... code for listing book list
var editor = new $.fn.dataTable.Editor( {
"ajax": {
"url" : 'textbook' + Book.book_code,
fields: [ {
label: "Book name",
name: "book_name"
}, {
label: "Title:",
name: "book_tiltle"
}
} );
Book.dataTable = $('#book-datatable').dataTable( {
"ajax": {
"url" : 'textbook' + Book.book_code,
"dataSrc": function(json) {
return json.data;
}
},
"responsive": true,
"bSort" : false,
"order": [],
"columns": [
{ "data": "book_name"},
{ "data": "book_tiltle" },
{ "data": "price" },
{
sortable: false,
"render": function ( data, type, full, meta ) {
return Book.save(full);
}
},
]
} );
},
But I am getting the error "TypeError: $.fn.dataTable.Editor is not a constructor" .Please help
This discussion has been closed.
Replies
It sounds like the Editor code might not be getting loaded, or possibly multiple versions of jQuery are being loaded on the page and one is overwriting another that has Editor attached to it.
Allan
While loading editor js, I am getting following error:
uncaught exception: DataTables Editor - remote hosting of code not allowed. Please see http://editor.datatables.net for details on how to purchase an Editor license
And before my datatables were working perfectly. The issue was with inline editing
I managed to load all js file, and included below code in my js
var editor = new $.fn.dataTable.Editor( {
} );
but again getting the same error - " $.fn.dataTable.Editor is not a constructor"
Have you purchased an Editor license?
Below code is working fine now. Thanks.
But another issue I got, when I edit the field, will it save automatically?
I have gone through the example - https://editor.datatables.net/examples/inline-editing/simple.html , it also doesn't save data
If you want to it save automatically when the field loses focus, use the
form-options
submitOnBlur
option:Allan