You need to sign in to do that
Don't have an account?

Lightning input and button is not working
Here goes my Lightning component -
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="cboard_seeContacts">
<aura:attribute name="accId" type="String" />
<aura:attribute name="Con" type="Contact"
default="{sObjectname: 'Contact',
FirstName:'Roza',
LastName:'Stalin',
Phone:'8981103780',
Email:'rozaStalin@cboard.com'}"/>
<div class="slds-p-around_medium">
<lightning:input name="First Name" type="text" label = "First Name" value="{!v.con.FirstName}"/>
<lightning:input name="Last Name" type="text" label = "Last Name" value="{!v.con.LastName}"/>
<lightning:input name="Phone" type="phone" label = "Phone" value="{!v.con.Phone}"/>
<lightning:input name="Email" type="email" label = "Email" value="{!v.con.Email}"/><br/><br/>
<lightning:button label="Quick Create Contact" variant="Brand" onclick="{!c.doSave}"/>
</div>
</aura:component>
Controller -
public class cboard_seeContacts {
@AuraEnabled
public static List<Contact> ContactList(string accId){
return [Select Id, FirstName,LastName from Contact where AccountId =:accId];
}
@AuraEnabled
public static Contact createContact(Contact c, Id AccountId){
c.AccountId=AccountId;
insert c;
return c;
}
}
JS-
({
doSave : function(component, event, helper) {
var action = component.get('c.createContact');
action.setParam({
c : component.get('v.Con'),
AccountId : component.get('v.accId')
});
action.setCallBack(this, function(response){
var state= response.getState();
if(state === 'SUCCESS' || state ==='DRAFT'){
var reposneValue = response.getReturnvalue();
}
},'ALL');
$A.enqueueAction(action);
}
})
I am unable to figure out why the inputs and button is not working. Any help will be appreciated.
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="cboard_seeContacts">
<aura:attribute name="accId" type="String" />
<aura:attribute name="Con" type="Contact"
default="{sObjectname: 'Contact',
FirstName:'Roza',
LastName:'Stalin',
Phone:'8981103780',
Email:'rozaStalin@cboard.com'}"/>
<div class="slds-p-around_medium">
<lightning:input name="First Name" type="text" label = "First Name" value="{!v.con.FirstName}"/>
<lightning:input name="Last Name" type="text" label = "Last Name" value="{!v.con.LastName}"/>
<lightning:input name="Phone" type="phone" label = "Phone" value="{!v.con.Phone}"/>
<lightning:input name="Email" type="email" label = "Email" value="{!v.con.Email}"/><br/><br/>
<lightning:button label="Quick Create Contact" variant="Brand" onclick="{!c.doSave}"/>
</div>
</aura:component>
Controller -
public class cboard_seeContacts {
@AuraEnabled
public static List<Contact> ContactList(string accId){
return [Select Id, FirstName,LastName from Contact where AccountId =:accId];
}
@AuraEnabled
public static Contact createContact(Contact c, Id AccountId){
c.AccountId=AccountId;
insert c;
return c;
}
}
JS-
({
doSave : function(component, event, helper) {
var action = component.get('c.createContact');
action.setParam({
c : component.get('v.Con'),
AccountId : component.get('v.accId')
});
action.setCallBack(this, function(response){
var state= response.getState();
if(state === 'SUCCESS' || state ==='DRAFT'){
var reposneValue = response.getReturnvalue();
}
},'ALL');
$A.enqueueAction(action);
}
})
I am unable to figure out why the inputs and button is not working. Any help will be appreciated.
Please find the updated code :
Component
<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="cboard_seeContacts">
<aura:attribute name="accId" type="String" />
<aura:attribute name="con" type="Contact"
default="{sObjectname: 'Contact',
FirstName:'Roza',
LastName:'Stalin',
Phone:'8981103780',
Email:'rozaStalin@cboard.com'}"/>
<div class="slds-p-around_medium">
<lightning:input name="First Name" type="text" label = "First Name" value="{!v.con.FirstName}"/>
<lightning:input name="Last Name" type="text" label = "Last Name" value="{!v.con.LastName}"/>
<lightning:input name="Phone" type="phone" label = "Phone" value="{!v.con.Phone}"/>
<lightning:input name="Email" type="email" label = "Email" value="{!v.con.Email}"/><br/><br/>
<lightning:button label="Quick Create Contact" variant="Brand" onclick="{!c.doSave}"/>
</div>
</aura:component>
JS-
({
doSave : function(component, event, helper) {
var action = component.get('c.createContact');
action.setParam({
c : component.get('v.Con'),
AccountId : component.get('v.accId')
});
action.setCallback(this, function(response){
var state= response.getState();
if(state === 'SUCCESS' || state ==='DRAFT'){
var reposneValue = response.getReturnvalue();
}
});
$A.enqueueAction(action);
}
})
Thanks for your help ! I am able to enter input correctly now, however the button remains non-functional. Could you please help ?
Thanks