jquery/javascript context menu item builder

jquery/javascript context menu item builder

I am trying to use the context menu script to build custom menus depending on what is clicked.  I am having trouble applying if statements to the items on the menu to custom build it based on circumstances.  Is there a work around for this?  I tried building an object array outside of the function and calling it but it didnt seem to recognize it.

*example.. add an if statement to include the edit item on the menu

$(function(){
        $.contextMenu({
            selector: '.context-menu-one',
            build: function($trigger, e) {
                return {
                    items:
                    {
                        "edit":
                        {
                            name: "Edit",
                            icon: "edit",
                            callback: function(key, options)
                            {
                                // some code to perform
                            }
                        },
                        "cut": {name: "Cut", icon: "cut"},
                        "copy": {name: "Copy", icon: "copy"},
                        "paste": {name: "Paste", icon: "paste"},
                        "delete": {name: "Delete", icon: "delete"},
                        "sep1": "---------",
                        "quit": {name: "Quit", icon: "quit"}
                    }   
                };
            }
        });
    });