1

In lightning, is it possible to call an Apex function just after a window.location.href ?

For example I have a function that save a pdf from a visualforce page into attachment, and in the lightning component, when I click a button, I want that the pdf (visualforce page with renderAs="pdf") is displayed and just after I want that the function saving the pdf to be called

window.location.href = "my location";
var action = component.get("c.attachPdf");
2

A browser, once instructed to go to a different page, automatically closes all of its open connections to the server and begins the process of removing all elements from memory. In other words, once you "leave" a page, there's absolutely nothing more that you can do script-wise, including calling to a server, saving page state into local storage, or anything else. Instead, call the Apex function first, and in the callback, perform your redirect.

3

Window.location.href completely gets you in a new context and window and hence you cannot do this .

When you move away from the component to a new browser window everything is destroyed .

All you can do at that point is to pass some URL parameters and take some actions based on that

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.