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
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 just take the same code but put it in another app like "" and it should work ;)