0

I'm using strophe.js for a pub/sub model that I want to implement in my aura component.However when the callback is triggered and I want to fire the component it gives an error setParams null. Since callback function only takes a single parameter I've moved all my code to controller so I have a cmp reference.

controller.js

handleLogin: function(cmp, event, helper) {
    connection.addHandler((function(msg){
        var x2js = new X2JS();

        try {
            var text = msg['firstElementChild']['firstElementChild']['textContent'];
            var obj = x2js.xml_str2json(text);
            console.log("On Message : ", obj);

            // here if I call $A.getCallback without window.setTimeout the function doesn't trigger.
            window.setTimeout(
                $A.getCallback(function() {
                    cmp.getEvent('renderPanel').setParams({
                        type : 'c:callInitiatedPanel',
                        attributes : {
                            'state' : 'Incoming',
                            'recordName' : 'hammad',
                            'phone' : 'phone',
                            'title' : 'title',
                            'account' : 'account',
                            'recordId' : 'rid',
                            'presence' : 'presence'
                        }
                    }).fire()
                }), 1000);
        } catch(e) {
            console.log("Error: ", e)
        }
    
        return true;
    }), null, 'message', null, null,  null);
}

1 Answer 1

1

Have you registered the event in component.cmp? Like this

<aura:registerEvent name="renderPanel" type="c:renderPanel"/>

Here is the reference on where you can get a sample code on how to work with Component Events in Aura https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_component_example.htm

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .