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):

PHP Code:
$(document).ready(function() {
buttons : [
name'Add'bclass'add'onpress item.add()},
name'Edit'bclass'edit'onpress item.edit()},
name'Delete'bclass'delete'onpress item.del()},

On the other hand, I'd like to know whether I can define the onpress callbacks so that they get encapsulated. Something like this:

PHP Code:
(function($) {
item = {
add: function() {
alert('add item');
edit: function() {
alert('edit item');
del: function() {
alert('delete item');
Logically, the callbacks will not work because item is encapsulated. How would you do this to prevent collisions? You might say join both snippets within the same closure. Problem is that I need the first one to be output from a template because it depends on PHP variables, whereas the second one is in a js file.