0

I have created codes for the controller js of my lightning component which uses a handler that takes the parameter value from an event:

checkChange: function(component, event, handler) {
    var test_Id = component.get("v.TEST_Id");

    if(condition 1){
        //some action using the test id
    }
    if(condition 2){
        //some action some action using the test id
    }
    if(condition 2){
        //some action some action using the test id
    }
}

how do you breakdown the codes from each if statement's action? Like, I tried creating the action from the helper js but it doesn't perform right like how i made it in the controller js. did the handler cause it?

this is quiet related to my question here How to get parameter value from event?

2

you can create function in helper and pass desired parameter to it. event could be passed as well

helper.js

({
    handleCheckChange : function(component, event){
        var test_Id = component.get("v.TEST_Id");
        // work with event in helper function
        if(condition 1){
            //some action using the test id
        }
        if(condition 2){
            //some action some action using the test id
        }
        if(condition 2){
            //some action some action using the test id
        }
    }
})

your controller will look like:

checkChange: function(component, event, helper) {
    helper.handleCheckChange(component, event);
}

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.