7

Having some problems dynamically creating a lightning:buttonMenu using $A.createComponents(). Creating the buttonMenu works fine but as soon as I try to add a lightning:menuItem I get the following when I click the menu:

error:

Uncaught Assertion Failed!: Descriptor for Config required for registration : undefined  throws at ...

helper method from component:

createFilterMenu: function(cmp) {
    var options = cmp.get('v.filterOptions')
    var menuOptions = [
        [
            'lightning:buttonMenu', {
                'aura:id': 'filterMenu',
                'iconName': 'utility:filterList',
                'alternativeText': 'Filter Selection',
                'value': cmp.getReference('v.filter'),
                'onselect': cmp.getReference('c.filterChange')
            }
        ],
        [
            'lightning:menuItem',{
                'label': 'test',
                'value': 'test'
            }
        ]
    ]
    $A.createComponents(
        menuOptions,
        function(components, status, errorMessage) {
            if (status === 'SUCCESS') {
                var menuDiv = cmp.find('menu')
                var menu = components[0]
                var item = components[1]
                menu.set('v.body',item)
                menuDiv.set('v.body', menu)
            } else if (status === 'INCOMPLETE') {
                console.log('No response from server or client is offline.')
            } else if (status === 'ERROR') {
                console.log('Error: ' + errorMessage)
            }
        }
    )
}
  • Can you help narrow it down? Whats in menu.set("v.body", item); ? can you remove as much as you can while still getting the error? – Kris Gray Apr 6 '17 at 22:29
  • This is a nested component example as mentioned here. menu.set('v.body',item) is setting the body for the lightning:buttonMenu with a lightning:menuItem. The hope is to be able to dynamically build that menu this way. – WarbleSync Apr 7 '17 at 13:01
  • Can I get the full stack trace? Can you break on the error and get more information? I tried to reproduce using your createComponents call, but it didn't happen. – Kris Gray Apr 7 '17 at 17:50
  • @Kris Gray Did you ever figure out what this was? Running into it myself. – Grekker Aug 25 '18 at 20:38
  • @WarbleSync I'm getting this same error in the exact same circumstances. I dynamically create a buttonMenu with child menuItems, and when I click on the buttonMenu the error is thrown. If I skip adding the children, clicking on the buttonMenu produces an empty dropdown and no error. Definitely related to the children somehow. Did you ever resolve this? – Grekker Aug 25 '18 at 20:52
1

Please refer to http://dfyjkt.blogspot.com/2018/09/is-it-impossible-to-dynamically.html

The reason is buttonMenu's body is Aura.ComponentDefRef, not the usual Aura.Component. The workaround in that post does not work for me, but it explains why it does not work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.