You need to sign in to do that
Don't have an account?
Heidi Apa
Inputselect undefined using find in lightning controller helper
Hi!
I have an error in a lightning component that I didnt have 2 weeks ago... I am trying to populate two input selects retrieving the values from apex, but when I try to find the input select I have the next error: [Cannot read property 'length' of undefined]
Component:
Controller:
Helper:
the push of "opts" its done correctly from apex but the variable inputsel is "undefined".... Any idea of whats going on?
Thank you!!!!
I have an error in a lightning component that I didnt have 2 weeks ago... I am trying to populate two input selects retrieving the values from apex, but when I try to find the input select I have the next error: [Cannot read property 'length' of undefined]
Component:
<ui:inputSelect aura:id="InputValueSelectDynamic" class="slds-input dynamic" labelClass="slds-form-element__label" required="true" />
Controller:
helper.getOptionsPicklist(component,"Value");
Helper:
getOptionsPicklist: function(component, valor) { component.set("v.mostrarSpinner", true); var action = component.get("c.getOptionsPicklist"); action.setParams({ "valor": valor }); var inputsel = component.find("Input"+valor+"SelectDynamic"); var opts=[]; action.setCallback(this, function(a) { for(var i=0;i< a.getReturnValue().length;i++){ opts.push({"class": "optionClass", label: a.getReturnValue()[i], value: a.getReturnValue()[i]}); } if(inputsel.length>0){ for(var j=0;j<inputsel.length;j++){ inputsel[j].set("v.options", opts); } } else{ inputsel.set("v.options", opts); }
the push of "opts" its done correctly from apex but the variable inputsel is "undefined".... Any idea of whats going on?
Thank you!!!!
Raj Vakati
try like below
Heidi Apa
Thank you Raj V, but not working either :(