send hidden field value in makeeditable loaddata variable
send hidden field value in makeeditable loaddata variable
I am a datatables newbie but hope someone can guide me in the right direction.
I am using makeeditable to generate a select box from a php function using loadurl which works just fine. The problem I am having is I need to send the id of the row to the function and I can't seem to figure out how to do it. I can create a static variable in loaddata but I can not set the value of a field to be the row id which is a hidden field in the datatable.
[code]
var exampleTable = $('#example').dataTable().makeEditable({
sUpdateURL: function(value, settings)
{
$.ajax({
type: "POST",
url: "<?php echo site_url('quotes/ajax/edit_datatables');?>",
data: ""
success: function(){
oTable.fnDraw();
}
})
return value;
},
aoColumns: [
{ },
{ event: 'click',
select: 'true'
},
{ },
{ },
{ },
{ event: 'click',
select: 'true'
},
{
onblur: 'submit',
type : "select",
loadurl: "<?php echo site_url('select/ajax/get_select');?>",
loadtype: 'POST',
loaddata: { "id": "2" }, // should be the value of the first datatable column which is a hidden column
//loaddata: { "id": oTable.fnGetData(oTable.fnGetPosition(this)[0])[0].toString() },
event: 'click',
select: 'true'
},
{ event: 'click',
select: 'true'
},
{ },
],
});
[/code]
Thanks in advance for the guidance.
Jon
I am using makeeditable to generate a select box from a php function using loadurl which works just fine. The problem I am having is I need to send the id of the row to the function and I can't seem to figure out how to do it. I can create a static variable in loaddata but I can not set the value of a field to be the row id which is a hidden field in the datatable.
[code]
var exampleTable = $('#example').dataTable().makeEditable({
sUpdateURL: function(value, settings)
{
$.ajax({
type: "POST",
url: "<?php echo site_url('quotes/ajax/edit_datatables');?>",
data: ""
success: function(){
oTable.fnDraw();
}
})
return value;
},
aoColumns: [
{ },
{ event: 'click',
select: 'true'
},
{ },
{ },
{ },
{ event: 'click',
select: 'true'
},
{
onblur: 'submit',
type : "select",
loadurl: "<?php echo site_url('select/ajax/get_select');?>",
loadtype: 'POST',
loaddata: { "id": "2" }, // should be the value of the first datatable column which is a hidden column
//loaddata: { "id": oTable.fnGetData(oTable.fnGetPosition(this)[0])[0].toString() },
event: 'click',
select: 'true'
},
{ event: 'click',
select: 'true'
},
{ },
],
});
[/code]
Thanks in advance for the guidance.
Jon
This discussion has been closed.
Replies
[code]
{
onblur: 'submit',
placeholder : "",
cssclass: 'input-small',
type : "select",
loadurl: "<?php echo site_url('select/ajax/get_select');?>",
loadtype: 'POST',
loaddata: { "item_id": $('#example').on('click', 'tbody tr', function (e) {
var item_id = $(this).closest('tr').attr('id');
alert($(this).closest('tr').attr('id'));
return item_id;
})
},
width: '100%',
event: 'click',
select: 'true'
},
[/code]
I am new to jquery so please be nice when you tell me why this won't work and what I should be doing instead :)
Thanks for the help,
Jon