You need to sign in to do that
Don't have an account?
Nithesh N
Toast Event not Firing and [Cannot read property 'setParams' of undefined] Error
Hey Everyone,
I am having trouble displaying the Toast message, in a simple Lightning component, Following os the code.
Cmp
Controller.js
helper.js
demo App
And This is the Error I am getting, when i tired to run it
Action failed: c:toastcomponent$controller$updateSearch [Cannot read property 'setParams' of undefined]
Failing descriptor: {c:toastcomponent$controller$updateSearch}
Please point out the mistakes i made.
Best,
Nithesh
I am having trouble displaying the Toast message, in a simple Lightning component, Following os the code.
Cmp
<aura:component implements="flexipage:availableForAllPageTypes" access="global"> <aura:attribute name="result" type="String" /> <div aura:id="input" class="slds-box small" > <div aura:id="panelList"> <header class="slds-m-bottom--small"> <div class="slds-media slds-media--center slds-m-bottom--small"> <div class="slds-media__figure"> <lightning:icon iconName="utility:answer" /> </div> <div class="slds-media__body"> <h2 class="slds-text-heading--small "> Text Analyzer </h2> </div> </div> <div class="slds-form-element"> <label class="slds-form-element__label slds-assistive-text" for="searchBox">Search</label> <div class="slds-form-element__control"> <ui:inputText aura:id="Text2Analyze" class="slds-input" placeholder="Enter any text..." change="{!c.updateSearch}"/> </div> </div> </header> </div> </div> </aura:component>
Controller.js
({ updateSearch : function(component, event, helper) { var inputText = escape(component.find("Text2Analyze").get("v.value")); console.log(inputText.length); helper.toastThis(inputText.length, 'Input text Length') } })
helper.js
({ toastThis : function(message, title) { var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ "title": title || "Error:", "message": message, "type": "error", "mode": "sticky" }); toastEvent.fire(); } })
demo App
<aura:application extends="force:slds"> <c:toastComponent /> </aura:application>
And This is the Error I am getting, when i tired to run it
Action failed: c:toastcomponent$controller$updateSearch [Cannot read property 'setParams' of undefined]
Failing descriptor: {c:toastcomponent$controller$updateSearch}
Please point out the mistakes i made.
Best,
Nithesh
toastEvent will have "undefined " always.
Therefore launch your toastComponent in LEX via app builder or lightning quickaction or drag to detail page to check how it works.
All Answers
toastEvent will have "undefined " always.
Therefore launch your toastComponent in LEX via app builder or lightning quickaction or drag to detail page to check how it works.
Hi Nayana/Nitesh,
I am using the
var resultsToast =$A.get("e.force:showToast"); and adding the component in the detail page but still it simply is not functional.
Regards,
Siddhartha
This my code but not working
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "The record has been updated successfully."
});
toastEvent.fire();