I want to invoke a method when inputfield is off from focus state(blur). I am trying as below but i am not able to get the alert statement when the cursor is out of focus from field . Can some one help me out here

In Component

<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
<label for="Subject">Subject</label>
<lightning:inputField fieldName="Subj"  aura:id="Subj" onchange="{!c.search}" value="{!v.sValue}" disabled="{!v.disableSubject}"/>

In Renderer

({ afterRender: function (component, helper) {
        var afterRend = this.superAfterRender();
        return afterRend;

In Helper

addListeners : function (component){
  var cmp = component.find("Subj");
  cmp.getElement().addEventListener("blur", function(){
        alert('Method invoked');
  • its not clear what you are trying to do, blur and 'cursor' hover are two different things, which one are you trying to achieve?
    – glls
    Feb 5 '19 at 14:06
  • I am trying to blur @glls Feb 6 '19 at 7:04
  • Does the javascript execution ever reach 'addListeners'? Your render-handler calls onRender, but the function you cite is called afterRender... Apr 18 '20 at 18:27
  • @Salesforcedeveloper, any answer you got on this? Aug 22 '20 at 8:16

Your Answer

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

Browse other questions tagged or ask your own question.