Hello everyone, I have only programmed old-school javascript and I’m not used to the way is it used nowadays (unobtrusive, encapsulated, using objects for everything, etc). So please bear with me if this question seems silly.
This is what I need:
I’m using a jQuery plugin called Flexigrid to create grids to list items. I’m not going to get into this. Just mention that I have configured these buttons in it (notice the callbacks):
[code=php]$(document).ready(function() {
$(‘#listado’).flexigrid({
//propiedades
…..
buttons : [
{name: ‘Add’, bclass: ‘add’, onpress : item.add()},
{name: ‘Edit’, bclass: ‘edit’, onpress : item.edit()},
{name: ‘Delete’, bclass: ‘delete’, onpress : item.del()},
{separator: true}
]
});
}
On the other hand, I’d like to know whether I can define the [B]onpress
[code=php](function($) {
var item = {
add: function() {
alert(‘add item’);
},
edit: function() {
alert(‘edit item’);
},
del: function() {
alert(‘delete item’);
}
}
})(jQuery);
Logically, the callbacks will not work because [B]item