[SalesForce] Reload Visualforce page on value change in Lightning Component inside

I am having a visualforce page inside which I am using a lightning component. Its shown below

            $Lightning.use("c:VFPage", function() {
                $Lightning.createComponent(
                    "c:EditAttachment",
                    {
                        attachmentId: attId,
                        attachmentName: attName,
                        attachmentDesc: attDesc,
                        isPrivate: isPrivate
                    },
                    "LightningContainer",
                    function(cmp) {
                    }
                );
            });

Inside the lightning component, I am performing an edit on Attachment record and saving it.

I want to reload the whole visualforce page after the saving of the attachment is successful. Is there any way to do this?

Best Answer

Simply Use location.reload();on the Success callback of the Attachment/record Save.It reloads the page.

You can also pass the attributes from lightning component to VF page by Fire the Navigate event to handle it on the VF page, Like this

Controller:

var objectHomeEvent = $A.get("e.force:navigateToObjectHome");
objectHomeEvent.setParams({

    scope: component.get('v.List')

});
objectHomeEvent.fire();

VF Page:

$Lightning.use("c:sObjectFilterApp", function() {
    $Lightning.createComponent("c:sObjectFilter",
    { label : "Press Me!" },
    "lightning",
    function(cmp) {

        $A.eventService.addHandler({
              event: 'force:navigateToObjectHome',
              handler: function(cmp,event) {

                   console.log(cmp.qc.scope);               
              }
        });

    });
});

But It was somewhere like hacking. The Only Happy path was Handling the Navigate event, not getting params.

Related Topic