I started using the revealing pattern and I'm starting to think if there isn't a better approach for this.....
var grid= (function(){
var grid='';
function init(gridOptions) {
cacheDom(gridOptions);
//this.bindEvents();
buildGrid(gridOptions);
}
function cacheDom(options) {
$greeder = $(options.selector);
/* this.$button = this.$el.find('button');
this.$input = this.$el.find('input');
this.$ul = this.$el.find('ul');
this.template = this.$el.find('#people-template').html();*/
}
function bindEvents() {
}
function buildGrid(options){
$.ajax({
method: "POST",
url: options.data,
data: $.param(options.parameters),
success: function(data) {
alert(data);
// generateGrid(data, options);
// styleGrid(options); //it can be default with bootstrap if the property style is undefined, if the user wants to put his own style he can use style:'custom' parameter
// generatePager(options);
// renderGrid(options);
}
});
}
function generateGrid(data, options){
}
function styleGrid(options){
}
function renderGrid() {
}
return {
init: init
};
})();
/* dataType: 'array', 'json', 'xml' possible values*/
grid.init({
title:'The grid',
selector:'#greeder',
data:'./api/getCustomers.php',
parameters: {"id_customer":"32"},
fields:{
id_customer:{
title:'ID customer'
},
first_name:{
title:'First Name'
},
last_name:{
title:'Last Name'
}
}
});
My main question is how could I do in the future if I want to inherit all the methods and properties to a subclass with my current approach.....I wonder if using something similar to some of the prototypal inheritance I saw is a better approach to extend functionality in the future.
You can see in the commented code how a musician add functionality on top of the human class really easily. My question is, which one of the two is better for this situation?......Which of the two gives me the best flexibility to add functionality in the future without code repetition?. I always prefer OOP over other paradigms, but it's nice to know what is best on each situation. Thank you very much.