0

I have below LDS Component, at the console log, I can see render and after render log but once I start typing in one of the input fields, I get nothing from rerender log. can someone please help me to get the log from rerender function?

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" >
    <aura:attribute name="recordId" type="String" />

        <lightning:card iconName="action:add_contact" title="Add Contact">
            <div class="slds-p-around_small">
            <lightning:recordEditForm 
                                      objectApiName="Contact"
                                      onsuccess="{!c.handleSuccess}">
                <lightning:messages />

                <lightning:inputField fieldName="Name" />
                <lightning:inputField fieldname="Languages__c" />
                <lightning:inputField fieldName="Birthdate" />
                <lightning:inputField fieldName="Phone" />
                <lightning:inputField fieldName="Email" />
                <lightning:inputField fieldName="LeadSource" />
                <lightning:inputField fieldName="Level__c" />
                <lightning:inputField fieldName="CleanStatus" />
                <lightning:button aura:id="submit" type="submit" label="Save" class="slds-m-top_medium" />
                <lightning:button aura:id="cancel" type="cancel" label="cancel" class="slds-m-top_medium" />
            </lightning:recordEditForm>
            <lightning:navigation aura:id="navService"/>
            </div>
        </lightning:card>   
</aura:component>

and below Renderer

({
    render : function (component, event, helper) {

    var act = this.superRender();

    console.log("This is from render function.");

    return act;
},
afterRender : function (component, event, helper) {

    var act = this.superAfterRender();

    console.log("This is from after render function.");
    //console.log("This is again from after render function.");       
},

rerender : function (component, event, helper) {

    var act = this.superRerender();

    console.log("This is from reRender function.");
    //console.log("This is again from reRender function.");       
},

unrender : function (component, event, helper) {

    var act = this.superUnrender();

    console.log("This is from unRender function.");
    console.log("This is again from unRender function.");       
} 

})

and just to avoid the X Y problem I am creating a contact with the LDS but I want a little addition to this, the exact scenario is once I type the name I want a function to fetch the value I have typed in a name without even hitting any buttons and then that value would be compared in the SOQL and if any duplicate contact matched then it will iterate the possible duplicate value(I haven't mentioned the iteration code yet), if I say the same thing in different words I am creating a contact and before hitting the save button I want to check whether this contact already exists in the database or not.

1
  • I think this may be an X-Y problem. You might want to ask about whatever it is you're trying to do; I believe you're probably chasing an invalid solution.
    – sfdcfox
    Commented Sep 9, 2018 at 15:25

1 Answer 1

3

Simply typing into a field by itself won't cause a rerender event. What needs to happen is at least one aura:valueChange event needs to fire, at which point the system will determine if a rerender needs to occur. Here's a demonstration of rerendering:

<aura:application >
    <aura:attribute name="rows" type="List" default="[]" />
    <aura:iteration items="{!v.rows}" var="item">
        <div>{!item}</div>
    </aura:iteration>
    <lightning:button label="Add" onclick="{!c.addrow}" />
</aura:application>

({
    addrow: function(component, event, helper) {
        let rows = component.get("v.rows");
        rows.push(rows.length);
        component.set("v.rows", rows);

    }
})

({
    rerender: function(component, event, helper) {
        var result = this.superRerender();
        console.log("rerender event fires");
        return result;
    }
})
8
  • So is this not possible with LDS?
    – gs650x
    Commented Sep 9, 2018 at 15:57
  • @gs650x LDS has nothing to do with anything you're asking about. Did you read about the x-y problem? In order to help you, we need to know your X, the basic problem you're trying to solve.
    – sfdcfox
    Commented Sep 9, 2018 at 15:59
  • What I am trying to achieve with this is when I start typing in the FirstName the value of the first name will set the parameter of an apex class and then the data I will get from the apex class I will Iterate in the component right below the inputfields
    – gs650x
    Commented Sep 9, 2018 at 16:00
  • in other words i want the values of the name to be the parameters of an apex class without even hitting any button.
    – gs650x
    Commented Sep 9, 2018 at 16:01
  • Please confirm if this is possible by any other mean as you are my only hope :(
    – gs650x
    Commented Sep 9, 2018 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .