You need to sign in to do that
Don't have an account?
SHAIK MOULALI369
lightning button executed only 2 times
While clickiing lightning button (Toggle), it has woring only 2 times and after not executing properly.
Component Code :
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="buttonLabel" type="String" default="Search Button"/>
<aura:attribute name="newLabel" type="String" default="New Button"/>
<aura:attribute name="isNewAvailable" type="Boolean" default="false"/>
<aura:attribute name="CarTypes" type="String[]" default="All Types,Sport Car,Luxury Car,Van"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:layout horizontalAlign="center">
<lightning:layoutItem padding="around-medium">
<lightning:select name="selectItem " aura:id="CarType" label="All Types" variant="label-hidden" >
<option value="" text="All Types"/>
<aura:iteration items="{!v.CarTypes}" var="CarType">
<option value="{!CarType}" text="{!CarType}"/>
</aura:iteration>
</lightning:select>
<lightning:button label="{!v.buttonLabel}" onclick="{!c.onSearchClick}" variant="brand"/>
<lightning:button variant='neutral' label="Toggle Button" onclick="{!c.toggleButton}" />
<aura:if isTrue="{!v.isNewAvailable}">
<lightning:button variant='neutral' label="{#v.newLabel}"/>
<aura:set attribute="else">
New button cannot be added here
</aura:set>
</aura:if>
</lightning:layoutItem>
</lightning:layout>
</aura:component>
Controller Code :
({
onSearchClick : function(component, event, helper) {
helper.handlerOnSeearchClick(component, event, helper)
},
toggleButton : function(component, event, helper) {
var CurrentValue = component.get("v.isNewAvailable");
console.log('Method is exicuted');
if(CurrentValue){
console.log('New value--1'+CurrentValue);
component.set("v.isNewAvailable","false");
}
else{
console.log('New value--2'+CurrentValue);
component.set("v.isNewAvailable","true");
}
},
doInit : function(component, event, helper) {
var CarTypes = component.set("v.CarTypes");
component.set("v.CarTypes", ['Sport Car','Luxury Car','Van']);
}
})
Helper Code :
({
handlerOnSeearchClick : function(component, event, helper) {
alert('Search Button was clicked');
}
})
this is my complete code, Kindly suggest how to resolve this type of Issues.
Below is the O/P of my my code.
Component Code :
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="buttonLabel" type="String" default="Search Button"/>
<aura:attribute name="newLabel" type="String" default="New Button"/>
<aura:attribute name="isNewAvailable" type="Boolean" default="false"/>
<aura:attribute name="CarTypes" type="String[]" default="All Types,Sport Car,Luxury Car,Van"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<lightning:layout horizontalAlign="center">
<lightning:layoutItem padding="around-medium">
<lightning:select name="selectItem " aura:id="CarType" label="All Types" variant="label-hidden" >
<option value="" text="All Types"/>
<aura:iteration items="{!v.CarTypes}" var="CarType">
<option value="{!CarType}" text="{!CarType}"/>
</aura:iteration>
</lightning:select>
<lightning:button label="{!v.buttonLabel}" onclick="{!c.onSearchClick}" variant="brand"/>
<lightning:button variant='neutral' label="Toggle Button" onclick="{!c.toggleButton}" />
<aura:if isTrue="{!v.isNewAvailable}">
<lightning:button variant='neutral' label="{#v.newLabel}"/>
<aura:set attribute="else">
New button cannot be added here
</aura:set>
</aura:if>
</lightning:layoutItem>
</lightning:layout>
</aura:component>
Controller Code :
({
onSearchClick : function(component, event, helper) {
helper.handlerOnSeearchClick(component, event, helper)
},
toggleButton : function(component, event, helper) {
var CurrentValue = component.get("v.isNewAvailable");
console.log('Method is exicuted');
if(CurrentValue){
console.log('New value--1'+CurrentValue);
component.set("v.isNewAvailable","false");
}
else{
console.log('New value--2'+CurrentValue);
component.set("v.isNewAvailable","true");
}
},
doInit : function(component, event, helper) {
var CarTypes = component.set("v.CarTypes");
component.set("v.CarTypes", ['Sport Car','Luxury Car','Van']);
}
})
Helper Code :
({
handlerOnSeearchClick : function(component, event, helper) {
alert('Search Button was clicked');
}
})
this is my complete code, Kindly suggest how to resolve this type of Issues.
Below is the O/P of my my code.
I see that the method is being called and what is the scenario you are trying or where are you seeing the issue?
Also, is this a trailhead question? or an implementation issue?
thanks.
this is not a trailhead quation, it was implementing my own app.
I am trying to implement a toggle button, Initially it was "New button cannot be added here",
Click 1 : When clicking toggle button i need to get "New Button",
Click 2 : again clicking toggle button again i get "New button cannot be added here"
Click 3 : When clicking toggle button i need to get "New Button",
Click 4 : again clicking toggle button again i get "New button cannot be added here"
Like wise.... but the above code only 2 clicks has working... remaining not working...
Kinldy suggest how to resolve this.