You need to sign in to do that
Don't have an account?
Srikanth T
.get is not a function: When i am getting the value of the input to js controller i am facing the error.
Component:
<aura:attribute name="negotiatePrice" type="Integer" />
<table class="slds-table slds-table--bordered slds-table--cell-buffer">
<tbody>
<aura:iteration items="{!v.userList}" var="con" aura:id="usrLst">
<tr>
<th scope="row">
<div class="slds-truncate" title="{!con.Name}">{!con.Name}</div>
</th>
<th scope="row">
<div aura:id="usrLic" class="slds-truncate" title="{!con.TotalLicenses}">{!con.TotalLicenses}</div>
</th>
<th scope="row">
<aura:iteration items="{!v.costList}" var="cst">
<aura:if isTrue="{!con.Name == cst.Name}">
<div class="slds-truncate" title="{!cst.License_Price_Per_Month__c}">{!cst.License_Price_Per_Month__c}</div>
</aura:if>
</aura:iteration>
</th>
<th scope="row" >
<div class="slds-truncate">
<input type="number" aura:id="myAtt" placeholder="Enter Negotiated Price" class="slds-input inputField" value="{v.negotiatePrice}" onchange="{!c.CalculatePrice}" />
</div>
</th>
</tr>
</aura:iteration>
</tbody>
</table>
Controller:
CalculatePrice : function(component, event, helper) {
alert('Calculate');
var nPrice = component.find("myAtt");
var negotiatePrice = nPrice.get("v.value");
alert('negotiatePrice'+negotiatePrice);
},
<aura:attribute name="negotiatePrice" type="Integer" />
<table class="slds-table slds-table--bordered slds-table--cell-buffer">
<tbody>
<aura:iteration items="{!v.userList}" var="con" aura:id="usrLst">
<tr>
<th scope="row">
<div class="slds-truncate" title="{!con.Name}">{!con.Name}</div>
</th>
<th scope="row">
<div aura:id="usrLic" class="slds-truncate" title="{!con.TotalLicenses}">{!con.TotalLicenses}</div>
</th>
<th scope="row">
<aura:iteration items="{!v.costList}" var="cst">
<aura:if isTrue="{!con.Name == cst.Name}">
<div class="slds-truncate" title="{!cst.License_Price_Per_Month__c}">{!cst.License_Price_Per_Month__c}</div>
</aura:if>
</aura:iteration>
</th>
<th scope="row" >
<div class="slds-truncate">
<input type="number" aura:id="myAtt" placeholder="Enter Negotiated Price" class="slds-input inputField" value="{v.negotiatePrice}" onchange="{!c.CalculatePrice}" />
</div>
</th>
</tr>
</aura:iteration>
</tbody>
</table>
Controller:
CalculatePrice : function(component, event, helper) {
alert('Calculate');
var nPrice = component.find("myAtt");
var negotiatePrice = nPrice.get("v.value");
alert('negotiatePrice'+negotiatePrice);
},
As per https://salesforce.stackexchange.com/questions/281201/error-component-find-get-is-not-a-function-in-lightning there is a bug because of the way aura:if renders content.
Please check if the workaround suggested in the article is feasible for your scenario.
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Thanks for the reply,
As per the above link, i am not using the input inside the aura:if, i am using that inside aura:iteration.
And i have tried this also, it's not working.
I see you are missing exclamation sign before v.negotiatePrice in below tag-
<input type="number" aura:id="myAtt" placeholder="Enter Negotiated Price" class="slds-input inputField" value="{v.negotiatePrice}" onchange="{!c.CalculatePrice}" />
Change it to below and try - If the issue persists, try changing <input> to <lightning:input> like below- Let me know if this helps!