1

Trying to pass a variable from one js controller function to another and having issues. The first function runs before the second and the console.log shows the Secondary attribute as defined before the the onButtonpressed triggers. Yet the Secondary attribute logs as undefined when the onbuttonpressed function runs.

Any ideas?

    onChildAttributeChange : function (component, event, helper) {
    console.log("Old value: " + event.getParam("oldValue"));
    var cuck = event.getParam("value") != null;
    component.get('v.secondary');
    component.set('v.secondary',cuck);
    console.log(component.get('v.secondary'));
},


 onButtonPressed: function(cmp, event, helper) {
     console.log(cmp.get('v.secondary'));
     if (cmp.get('v.secondary')) {
         // Figure out which action was called
         var actionClicked = event.getSource().getLocalId();
         // Fire that action
         var navigate = cmp.get('v.navigateFlow');
         navigate(actionClicked);
     } else {
         alert('Last One 10000');
     }
 }

Relevent Component Code

   <aura:attribute name="canPause" type="Boolean" />
   <aura:attribute name="canBack" type="Boolean" />
   <aura:attribute name="canNext" type="Boolean" />
   <aura:attribute name="canFinish" type="Boolean" />
   <aura:attribute name="childAttribute" type="String"/>

   <aura:handler name="change" value="{!v.childAttribute}" action=" . 
   {!c.onChildAttributeChange}"/>
   <aura:attribute name="secondary" type="Boolean"/>
   <aura:handler name="init" value="{!this}" action="{!c.init}" />

Any ideas, am i thinking about this incorrectly?

0

What is value you are assigning to secondary attribute I can't see you are setting any value to secondary attribute.set a default value first either true or false as below

    <aura:attribute name="secondary" type="Boolean" default="true"/>
  • Value is assigned in the parent controller. I didnt want to include all my code as to not overwhelm but on console.log(component.get('v.secondary')); in onchildattributechange the attribute is defined (and onbuttonpressed has not been run) – Bobbygllh Feb 15 at 14:06

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.