swisnl / jQuery-contextMenu

jQuery contextMenu plugin & polyfill
https://swisnl.github.io/jQuery-contextMenu/
MIT License
2.25k stars 745 forks source link

How to change the label at runtime? #743

Open crystalfp opened 3 years ago

crystalfp commented 3 years ago

I have defined menu items with a function for disabled and another for icon changing the menu entry depending on the program status. Now I want to change the menu entry label too, but seems there is no mechanism in place to to this. Is it a missing functionality or there is another method to change the label? I'm using the 3.x branch. Thanks! mario

crystalfp commented 3 years ago

Ugly workaround. Create entries with the different labels and use visible attribute to show the correct one:

                archive: {
                    name: "Archive",
                    callback: archiveProject,
                    icon: "fa-archive",
                    visible: () => status !== "ARCHIVED"
                },
                dearchive: {
                    name: "De-Archive",
                    callback: deArchiveProject,
                    icon: "fa-archive",
                    visible: () => status === "ARCHIVED"
                    }
                },

Using branch 3.x. Hoping in a better solution...