function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Christian BöhmeChristian Böhme 

Pass an Aura.Action when dynamically creating components

Hello,

I have a component, which has an aura:attribute with the type Aura.Action and a button, which calls this action.
<aura:attribute name="onproceed" type="Aura.Action" default="{!c.defaultCloseAction}"/>

<button onclick="{!v.onproceed}" />

Now I want to dynamically create this component in my controller and pass my custom action as a parameter to this component:
openWindow : function(component,event,helper) {

        $A.createComponent(
            "c:windowComponent",
            {
                "onproceed": function(){
                    alert('Success');
                }
            },
            function(window){
                if (component.isValid()) {
                    var targetCmp = component.find('windowDiv');
                    var body = targetCmp.get("v.body");
                    body.push(window);
                    targetCmp.set("v.body", body); 
                }
            }
        );
    },
There comes the error message: "action.runDeprecated is not a function".
What type of action should I pass here? Is it possible to do it with such a callback?
Do I have to pass my custom method from the controller?

A workaround for me would be to do it with events, but maybe this solution works somehow.
Tony White (BNE)Tony White (BNE)
I have the method defined in the controller creating the component and use component.getReference("c.functionname") to pass it to the create component function....