You need to sign in to do that
Don't have an account?
Derrick Koon 7
Lightning creation of UI components dynamically (programmatically) failed
We created a component with .cmp file with a section below:
<div aura:id="ElementHere"></div>
Then in the Helper JS class, we want to create ui:inputText control dynamically and place them at the div with aura:id="ElementHere":
createInputText : function(cmp, textLabel) {
var componentConfig = {
"componentDef": "markup://ui:inputText",
"attributes": {
"values": { label:textLabel, size:10, default:"enter text" }
}
};
$A.componentService.newComponentAsync(
this,
function(newInputText){
var divElementHereComponent = cmp.find("ElementHere");
var divElementHereBody = divElementHereComponent.get("v.body");
divElementHereBody.push(newInputText);
divElementHereComponent.set("v.body", divElementHereBody);
},
componentConfig
);
},
When we ran the app, we got a pop-up that complained that divElementHereComponent does not have get method.
Does anyone know if this is a bug, or we have missed some steps?
Thanks,
Derrick
<div aura:id="ElementHere"></div>
Then in the Helper JS class, we want to create ui:inputText control dynamically and place them at the div with aura:id="ElementHere":
createInputText : function(cmp, textLabel) {
var componentConfig = {
"componentDef": "markup://ui:inputText",
"attributes": {
"values": { label:textLabel, size:10, default:"enter text" }
}
};
$A.componentService.newComponentAsync(
this,
function(newInputText){
var divElementHereComponent = cmp.find("ElementHere");
var divElementHereBody = divElementHereComponent.get("v.body");
divElementHereBody.push(newInputText);
divElementHereComponent.set("v.body", divElementHereBody);
},
componentConfig
);
},
When we ran the app, we got a pop-up that complained that divElementHereComponent does not have get method.
Does anyone know if this is a bug, or we have missed some steps?
Thanks,
Derrick
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.
Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.
Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker