protected function getRedirectUrl()
    {
        if ($this->ajax()) {

            $lastSegment = last($this->segments());

            $routePrefix = $this->getRouteHelper()->getRouteNameForModelClass(
                $this->modelInformation->modelClass(),
                true
            );

            // If the model slug is the last segment, and this is a POST request, this is the STORE action.
            if ($lastSegment == $this->getRouteHelper()->getModelSlugForCurrentRoute() && $this->method() == 'POST') {

                $this->redirect = cms_route("{$routePrefix}.create");

            } elseif ($lastSegment == 'update') {

                $this->redirect = cms_route("{$routePrefix}.edit");
            }
        }

        return parent::getRedirectUrl();
    }