Attaching custom property to a MenuItem

I am creating a Picker (with PickerDecorator) and filling it during runtine ,by doing $.picker.CreateComponenets([..]);
I would like to attached for each MenuItem in that Picker a custom property that can be later used on selection of this MenuItem; like ID, or even an object of some sort.

How can this be done?


  • You can just put it on the component as a property in its declaration.

    this.$.picker.createComponents([{kind: enyo.Control, customProperty: "value"},...]);

    And then when you reference that component, customProperty should be set on it.
  • The only thing to be careful of here is to not override a property that Enyo actually uses for something. I probably do this with "id" on average once a month, and it takes a while to figure out why my app is breaking (the "id" gets used as the DOM node id, which has various restrictions on valid values).
  • it's working!! thanks.
    where is the documentation on that as i missed it.
  • I'm not sure there is documentation about it. It's POJS (plain ol' JavaScript) for objects to put properties on them like this.
  • edited February 2013
    even if it seems that its already solved for you - I just want to point out another option, cause I just had to solve that in my project.

    I just created a new kind extending MenuItem like this:
        name : "MyMenuItem",
        kind : "onyx.MenuItem",
        published : {
            value : undefined,
            originalElement : undefined
        create : function(inSender, inEvent) {
        valueChanged : function(inSender, inEvent) {
            if (this.value != null) {
    With that I can use get-/set-functions even for my custom properties.
        kind : "MyMenuItem",
        value : myVal,
        originalElement : myJSObject
    - Jan
Sign In or Register to comment.