In my lightning component, calling a method on onclick event and in turn which calls an another component. which works fine but whenever the page is refreshed it fails to call the component on First Click but works fine on second onClick

<ul aria-describedby="option-drag-label" aria-labelledby="label-46" aria-multiselectable="true" role="listbox" tabindex="0">
              <ui:inputSelect multiple="true" value="{!v.removeSelectedValues}" aura:id="rightSelectedValues" class="oSelect" click="{!c.getFieldDataType }" />

Onclick in the lightning component calls the below method

    getFieldDataType : fucntion(component, event, helper){
       var mffldName = component.get("v.mffldName");
                  this.showFieldPropertySet(component, mffldName);

And after the response,a method in which the component is created.

showFieldPropertySet : function(component, mffldName){
        var mfId=component.get("v.mfId");
        var mffType = component.get("v.mffType");
        var ObjectName= component.get("v.mfObjName");

                'mffType': mffType, 
                'selOption': mffldName   
  • A click is not the same as a page refresh, additionally, you are not sharing how you are calling your method. Please update your post – glls Dec 21 '17 at 14:28
  • Try clearing v.body after creating the component but before setting it. – techbusinessman Dec 22 '17 at 2:26
  • @glls yeah sure I will update the post :) sorry I didn't convey properly the thing is after page refresh it fails to call the component on First Click , but works like charm on secind click – SFDC Dec 22 '17 at 5:46
  • have you declared aura:dependency in your cmp file, that generally improve performance for dynamically created component. – Manjot Singh Jan 31 '18 at 7:29

instead of using ui:select use lightning:select

<lightning:select name="colorId" label="Select a color:" aura:id="colorId" value="{!v.selectedValue}" onchange="{!c.getFieldDataType}">
    <aura:iteration items="{!v.options}" var="option">
        <option text="{!option.label}" value="{!option.id}" selected="{!option.selected}"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.