Closed alpastar closed 5 years ago
Yeah it will not update names. Perhaps you should build the menu on open using the build
option. Then if you change the source object of the menu you can change names of the options.
https://swisnl.github.io/jQuery-contextMenu/demo/dynamic-create.html
Another options is to have 2 menu elements for both menu states, and show the correct one, but im not sure if this is realistic in your usecase.
I am facing the same problem as @alpastar. Thanks for the hint, @bbrala , I will try that. Nevertheless, the question is whether there is a specific reason why name is not changed (also it seems icon does not change as well)? In other words: Do you think you could at that? Would be great!
EDIT: I did a quick test with the build option: works! Thanks a lot! But if it would be possible to change name and icon through the update method.
The update method only goed through the menu and checks a few things. Changing the name of the element would mean the menu needs to be rebuilt, since the name is also used as reference for callbacks and such unfortunately, so getting everything to update will be problematic.
Updating the icon might be possible, but this would probably break if you change from the different supported icon types (fontawesome or classbased), so it would not really be a stable piece of code without being too complex.
os = windows-7 browser = chrome 68(64 bit)
$(selector).contextMenu('update') changes state of disabled, visible(icon, input-val) but !! , not name !!!!!!!!!!!! is there any way to dynamically change name ?
for example options.items['key1'].disabled = true ; // work options.items['key1'].visible = true ; // work options.items['key1'].name = 'some-other-name' ; // don't work $('.ui-some').contextMenu('update');
i'd like to avoid menu recreation , amongst many reasons, this is what i confronted...
$.contextMenu( 'destroy', ".ui-pg-div"); // don't work , $.contextMenu( 'destroy', $(".ui-pg-div")); // work , but destroys other menu also.(upper selector) not sure whether it has a relation with event bubbling. (i am not a javascript expert (ㅜㅜ)