1

I have built a lightning app containing 2 components.

1)Comp1 is the login page. Comp2 is the registration page. 2) After logging in user is taken to the registration page. User enters data here that goes into salesforce.

I want to -

1) To Show the progress while the record is being saved. 2) Refresh the page once data is saved.

I tried using $A.get("e.force:refreshView") but I am getting error as this event is being returned as null. Am I missing something?

4

Events like $A.get("e.force:refreshView") are only available in the context of Salesforce1 application. If you are not running inside SF1 then you have to use standard javascript means, like window.location.reload() or window.location.href = ...

  • Thanks gaiser. Can you please explain what do you mean by in the context of Salesforce1 application? Is that a separate framework you are talking about? window.location.reload() does reload the page but it takes me back to the login page. I want my current component i.e. registration page to be shown. How can I get my current component to refresh? – Vandana Mar 13 '15 at 2:27
  • context of Salesforce1 application means that your component/app is running inside Salesforce1, not normal salesforce. With regards to window.location.reload() - this may be specific to how you implemented your lightning App. I used this approach before (in a standalone app, not in Salesforce1) and it worked as expected. Try using window.location.href instead, to see if that makes any difference. – gaiser Mar 16 '15 at 17:07
1

I just ran into this and found what I think is a better solution.

If you have a component that is rendering a cell for a single object, and you want to do things like dynamically getting an icon, or some other call, then re-render once it's returned (which I think is a pretty common thing), you can simply wrap the entire cell in an <aura:iteration> tag.

Your component might look like this:

<aura:attribute name="render_list" type="List" />
<aura:attribute name="item" type="Object" />
<aura:iteration items="{!v.render_list}" var="render" indexVar="indx">
 {!v.item.name}
</aura:iteration>

And your callback code might do this:

var item = component.get("v.item");
var render_list = [item];
component.set("v.render_list", render_list);

This is taking advantage of <aura:iteration> being aware that it needs to re-render it's contents on change. Much easier to control what happens and localize where a re-render needs to happen at an object level.

0

Have you tried your apps in Lightning Experience or not? You can follow this link for more info about using force:refreshView: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_refreshView.htm

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.