Jeditable: setting settings.loadurl in the callback
Jeditable: setting settings.loadurl in the callback
I have a problem getting USER_ID to form the first url parameter of `Jeditable`.
USER_ID is the first cell value, normally I extract it like this: `$(this).closest('tr').children().first().text()`.
In `fnDrawCallback`, `this` variable has the whole table, but I can get this USER_ID in `callback` of `Jeditable`.
Is it possible to set url in the callback? How do I refer to settings.loadurl of editable?
[code]
var oTable = $('#main_data_table').dataTable({
// ...
"sAjaxSource": getApiUrl("/users"),
"aoColumns": aoColumns,
"aoColumnDefs":[{
"aTargets": [1],
"bSortable": false,
"mRender": function ( val, type, full ) {
return '' + val + '';
}
}],
"fnDrawCallback": function( oSettings ) {
// On this stage, 'this' has the whole table so I can't get USER_ID
$('td .editable', oTable.fnGetNodes()).editable(getApiUrl("/user/@@I_NEED_USER_ID_HERE@@/user_ref"), {
"callback": function( sValue, y ) {
// Here I can get USER_ID
var USER_ID =getApiUrl("/user/" + getUserid(this) + "/user_ref");
},
"submitdata": function ( value, settings ) {
return {
// ...
};
},
"height": "14px",
});
}
});
[/code]
USER_ID is the first cell value, normally I extract it like this: `$(this).closest('tr').children().first().text()`.
In `fnDrawCallback`, `this` variable has the whole table, but I can get this USER_ID in `callback` of `Jeditable`.
Is it possible to set url in the callback? How do I refer to settings.loadurl of editable?
[code]
var oTable = $('#main_data_table').dataTable({
// ...
"sAjaxSource": getApiUrl("/users"),
"aoColumns": aoColumns,
"aoColumnDefs":[{
"aTargets": [1],
"bSortable": false,
"mRender": function ( val, type, full ) {
return '' + val + '';
}
}],
"fnDrawCallback": function( oSettings ) {
// On this stage, 'this' has the whole table so I can't get USER_ID
$('td .editable', oTable.fnGetNodes()).editable(getApiUrl("/user/@@I_NEED_USER_ID_HERE@@/user_ref"), {
"callback": function( sValue, y ) {
// Here I can get USER_ID
var USER_ID =getApiUrl("/user/" + getUserid(this) + "/user_ref");
},
"submitdata": function ( value, settings ) {
return {
// ...
};
},
"height": "14px",
});
}
});
[/code]
This discussion has been closed.