What is renderAjax(), how is it different from render()?

后端 未结 2 1289
抹茶落季
抹茶落季 2021-01-12 01:58

When I use normal return this->render(\'create\', [\'model\' => $model]) my pop-up window goes all haywire. When I change to return $this->render

2条回答
  •  灰色年华
    2021-01-12 03:02

    render() public method

    Renders a view.

    The view to be rendered can be specified in one of the following formats:

    path alias (e.g. "@app/views/site/index"); absolute path within application (e.g. "//site/index"): the view name starts with double slashes. The actual view file will be looked for under the view path of the application. absolute path within current module (e.g. "/site/index"): the view name starts with a single slash. The actual view file will be looked for under the view path of the current module. relative view (e.g. "index"): the view name does not start with @ or /. The corresponding view file will be looked for under the view path of the view $context. If $context is not given, it will be looked for under the directory containing the view currently being rendered (i.e., this happens when rendering a view within another view).

    renderAjax() public method

    Renders a view in response to an AJAX request.

    This method is similar to render() except that it will surround the view being rendered with the calls of beginPage(), head(), beginBody(), endBody() and endPage(). By doing so, the method is able to inject into the rendering result with JS/CSS scripts and files that are registered with the view.

    renderAjax()

    render()

提交回复
热议问题