i have a program and i was thinking to create an object then a function inside it. is it possible? it's like this var x = function() {....}
and i wanted to re use the variable x..
here's the code:
$("#tbl").jqGrid({
url: '',
datatype: 'local',
jsonReader : {
root: function(obj) {
//some codes here
return root;
},
page: "page",
total: "pageCount",
records: "rows",
repeatitems:false,
id: "0"
},
serializeGridData: function(postData) {
var jsonParams = {
.
.//some codes here
.
'sort_fields': postData.sidx
};
if (postData.sord == 'desc')
{
..//some codes
}
else
{
...//some codes
}
jpar = jsonParams;
return 'json=' + jsonParams;
},
loadError: function(xhr, msg, e) {
showMessage('msg error');
},
colNames:['ID',...'Type'],
colModel:[
...//col model
],
rowNum:5,
.
.
.//some codes here
loadonce:false,
caption: "Main Account Group"
});
i want to get the jsonReader, serializedGridData, and the loadError and create an object function for them. my goal here is to create an object from the functions from the above code. does anybody here knows how to do it?
by the way, what's the difference between methods and functions.? can event can be code as function? thank you all.