+ Start a Discussion
Daniel Glaser 12Daniel Glaser 12 

Trailhead Aura $A.createComponents in javascript doesn't see to work

I am attempting to use the examples on Trailhead Lightning component "Using JavaScript Controllers with Components" and when I use the examples that use the $A.createComponents none of the JS work.

I created a component createComponent.cmp with the following code:
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <p>Dynamically created button</p>

and a controller createComponentController.js with the following code:
    doInit : function(cmp) {
                "aura:Id": "findableAuraId",
                "label": "Press Me",
                "press": cmp.getReference("c.handlePress")
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    cmp.set("v.body", body);

    handlePress : function(cmp) {
        console.log("button pressed");

This is right out of the book. The message "Dynamically created button" shows on the screen, but there are no buttons.
Stephane Paquet 9Stephane Paquet 9
What is the name of your app? if it is TestApp.app just take the same code but put it in another app like "ThisApp.app" and it should work ;)