Datatables Editor

Datatables Editor

ramhanumanramhanuman Posts: 2Questions: 0Answers: 0
edited September 2012 in General
I am following this tutorial (http://editor.datatables.net/tutorials/api_manipulation)
But for some reason my code doesn't end up working. Here's my html code:

[code]

Add new person



First Name
Last Name
Phone
Email
Ethnicity
Edit
Delete




[/code]

The table won't appear unless the user selects a certain option which is why it is hidden by default. Here's my jquery code:
[code]
$(document).ready(function(e) {
var editor = new $.fn.dataTable.Editor( {
"domTable": "#reg_more"
} );
$("input[name= 'Reg_num_r']").change( function () {
if($(this).val()==1) {
$('#Reg_num2').hide();
} else {
$('#Reg_num2').show();
$('#reg_more').dataTable({
"aoColumns": [
{ "mDataProp": "First Name" },
{ "mDataProp": "Last Name" },
{ "mDataProp": "Phone" },
{ "mDataProp": "Email", "sClass": "center" },
{ "mDataProp": "Ethnicity", "sClass": "center" },
{
"mDataProp": null,
"sClass": "center",
"sDefaultContent": 'Edit',
"bSortable": false,
"bSearchable": false
},
{
"mDataProp": null,
"sClass": "center",
"sDefaultContent": 'Delete',
"bSortable": false,
"bSearchable": false
}
]
});
}
$("#submit").show();
});
editor.add( [
{
"label": "First Name:",
"name": "fname"
}, {
"label": "Last Name:",
"name": "lname"
}, {
"label": "Phone:",
"name": "phone"
}, {
"label": "Email:",
"name": "email"
}, {
"label": "Ethnicity:",
"name": "ethnicity"
}
] );

$('button.editor_create').on('click', function (e) {
e.preventDefault();

editor.create(
'Add new person',
{
"label": "Add",
"fn": function () {
editor.submit()
}
}
);
} );

$('#reg_more').on('click', 'a.editor_edit', function (e) {
e.preventDefault();

editor.edit(
$(this).parents('tr')[0],
'Edit record',
{
"label": "Update",
"fn": function () { editor.submit(); }
}
);
} );

$('#reg_more').on('click', 'a.editor_remove', function (e) {
e.preventDefault();

editor.message( "Are you sure you want to remove this row?" );
editor.remove(
$(this).parents('tr')[0],
'Delete row',
{
"label": "Update",
"fn": function () {
editor.submit()
}
}
);
} );
[/code]

Can anyone see anything wrong with this? The code is almost EXACTLY the same as the code in the tutorial, i don't understand what I'm doing wrong.
This discussion has been closed.