How to do a Full Page Reload After Delete or Update For GroceryCRUD Enterprise Version: 2.7.9?

Does anyone know how to do a full page reload for GroceryCRUD Enterprise Version: 2.7.9?

I have tried the following:

  1. Use of header(“Location:”)
  2. Use of redirect(“controller/functionname”)
  3. Use of echo to add javascript that reloads the page:
    echo '<script>
            top.window.location=http://mysite/somepage.php";
            die;
          </script>';

Thank you in advance!

Hello @larasmith ,

The code that you are trying to apply it is blocked by the JavaScript that we use as this can cause XSS attacks. On the other side, you can use the JavaScript callbacks that we have here: unsetAutoloadJavaScript | Grocery CRUD

For example:

$(document).ready(function () {
    $('.gc-container').groceryCrud({
        callbackAfterUpdate: function (currentForm) {
            window.location = 'http://mysite/somepage.php';
        },
    );
});

Please keep in mind that if you upgrade to the latest Grocery CRUD Enterprise, you can also use the RedirectResponse class as per documentation here: Full Page Redirection | Grocery CRUD

Regards
Johnny

1 Like

Thank you for this response :blush:
I was not able to apply it though because I already have a workaround:

      $crud->callbackAfterInsert(function ($stateParameters) {
          $this->m_ImportDatabase->addHistory($stateParameters->insertId);

          $msg = '<script>
                    $(document).ready(function () {
                      $(".gc-error-modal-dialog").hide();
                    });
                    
                    top.location.reload();
                  </script>';

          return (new \GroceryCrud\Core\Error\ErrorMessage())->setMessage($msg);
      });  

In the script, I hide the container of the error dialog box then triggered the reload.
It’s not proper though but does the work :sweat_smile:

1 Like

Oh god, you literally hacked the system and find something that I haven’t thought :slight_smile:

1 Like