Global settings in makeEditable

Global settings in makeEditable

arnimarnim Posts: 5Questions: 0Answers: 0
edited October 2011 in Plug-ins
hello,

is there a way to define f.e. onblur and submit globally inside makeEditable instead of repeating it in every aoColumns-section?

how could the following code be changed to avoid repeating the identical options?

[code]
$(document).ready( function () {
$('#example').dataTable().makeEditable({
sUpdateURL: "UpdateData.php",
"aoColumns": [
null,
{
},
{
indicator: 'Saving Browser...',
tooltip: 'Click to edit browsers',
type: 'textarea',
onblur: 'cancel',
submit:'Save changes',
fnOnCellUpdated: function(sStatus, sValue, settings){
alert("(Cell Callback): Cell is updated with value " + sValue);
}
},
{
indicator: 'Saving platforms...',
tooltip: 'Click to edit platforms',
type: 'textarea',
onblur: 'cancel',
submit:'Save changes',
fnOnCellUpdated: function(sStatus, sValue, settings){
alert("(Cell Callback): Cell is updated with value " + sValue);
}
}
]
});
})
[/code]

regards
arnim

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited October 2011
    not sure you could create a true default, but you can use the $.extend() and a default settings object to simulate it

    see http://api.jquery.com/jQuery.extend/

    [code]

    $(document).ready( function () {
    // this is the global default
    defaultEditable = {
    tooltip: 'Click to edit browsers',
    type: 'textarea',
    onblur: 'cancel',
    submit:'Save changes',
    fnOnCellUpdated: function(sStatus, sValue, settings){
    alert("(Cell Callback): Cell is updated with value " + sValue);
    };
    };

    $('#example').dataTable().makeEditable({
    sUpdateURL: "UpdateData.php",
    "aoColumns": [
    null,
    { },
    $.extend({ }, defaultEditable, { indicator: 'Saving Browser...' }),
    $.extend({ }, defaultEditable, { indicator: 'Saving Platform...' }),
    ]
    });
    });
    [/code]
  • arnimarnim Posts: 5Questions: 0Answers: 0
    hello fbas,

    this works great, thanks a lot! it even overwrites settings from defaultEditable if they're set again in aoColumns.
This discussion has been closed.