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
mukesh guptamukesh gupta 

Create Component ui:inputCheckbox

Hi Expert ,

I am creating dynamic check boxes that's crated perfect, change event is not working for created check boxes;

when i select any check box then get error
getting error :- Unable to find action 'handleSelectedOLI' on the controller 
 
for(var i = 0; i<5; i++){
 $A.createComponent(
            "ui:inputCheckbox",
            {
                "aura:id": "checkBoxOLI",
                "value":chekboxVal,
                "change": component.getReference("c.handleSelectedOLI")
            },
            function(newButton, status, errorMessage){
                //Add the new button to the body array
                if (status === "SUCCESS") {
                    var body = component.get("v.body");
                    //body.push(newButton);
                    component.set("v.body", newButton);
                }
                else if (status === "INCOMPLETE") {
                    console.log("No response from server or client is offline.")
                    // Show offline error
                }
                else if (status === "ERROR") {
                    console.log("Error: " + errorMessage);
                    // Show error message
                }
            }
        );  
		
handleSelectedOLI: function(component, event, helper) {
        alert('change ecevt ');
    
    },

Please suggest

Regards
Mukesh
Abhishek BansalAbhishek Bansal
Hi Mukesh,

Just made some slight changes to your code, please try with the below code:
for(var i = 0; i<5; i++){
 $A.createComponent(
            "ui:inputCheckbox",
            {
                "aura:id": "checkBoxOLI",
                "value":chekboxVal,
                "change": component.getReference("c.handleSelectedOLI")
            },
            function(newButton, status, errorMessage){
                //Add the new button to the body array
                if (status === "SUCCESS") {
                    var body = component.get("v.body");
                    //body.push(newButton);
                    component.set("v.body", newButton);
                }
                else if (status === "INCOMPLETE") {
                    console.log("No response from server or client is offline.")
                    // Show offline error
                }
                else if (status === "ERROR") {
                    console.log("Error: " + errorMessage);
                    // Show error message
                }
            }
        );  
    },

	handleSelectedOLI: function(component, event, helper) {
        alert('change ecevt ');
	}

Let me know if yot still see any issues.

Thanks,
Abhishek Bansal.
mukesh guptamukesh gupta
Hi Abhishek,

It's not working , I missed a currely brace in this code. but not working as per your code

Regards
Mukesh