You could make an object with all the default options first, then use $.extend()
to merge in the changes/new properties.
var myDefaults = {
submitdata: {
ItemId: '@ViewData["ItemId"]'
},
cssclass: 'inherit',
indicator: 'wird gespeichert...',
style: 'display:inline',
height: '15px',
width: '150px',
placeholder: '<span class="muted">Zum Bearbeiten doppelklicken...</span>',
tooltip: 'Zum Bearbeiten doppelklicken...',
event: 'dblclick',
submit: '<button class="btn btn-mini btn-primary btn-forced-margin" type="submit" >OK</button>'
};
$(".selector").editable("/Controller/Method", $.extend(true, {}, myDefaults, {
data: " {'A':'A','B':'B','C':'C'}",
width: '15px'
});
The $.extend() syntax is slightly tricky, so you can use .bind() to roll your own.
// create a function with your default parameters for $.extend()
var editableParams = $.extend.bind({}, true, {}, myDefaults);
// usage
$(".selector").editable("/Controller/Method", editableParams({
data: " {'A':'A','B':'B','C':'C'}",
width: '15px'
});
Demo at http://jsfiddle.net/6GQ9Y/
$.extend()
docs at http://api.jquery.com/jQuery.extend/
.bind()
reference (and shim): https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind
UPDATE
The .bind() method above is basically just a fancy way of creating a new function. It seems, however, that it is not supported in IE 8 and older. The same "shortcut" can be achieved with the following code:
function editableParams(options) {
return $.extend(true, {}, myDefaults, options);
}