Commit 13b7c8e8 by Qiang Xue

refactored Pjax. Added title change support. [skip ci]

parent a872d605
......@@ -89,15 +89,17 @@ class Pjax extends Widget
$this->options['id'] = $this->getId();
}
if ($this->requiresPjax()) {
ob_start();
ob_implicit_flush(false);
if ($this->requiresPjax()) {
$view = $this->getView();
$view->clear();
$view->beginPage();
$view->head();
$view->beginBody();
if ($view->title !== null) {
echo Html::tag('title', Html::encode($view->title));
}
}
echo Html::beginTag('div', $this->options);
}
......@@ -108,15 +110,18 @@ class Pjax extends Widget
public function run()
{
echo Html::endTag('div');
if ($requiresPjax = $this->requiresPjax()) {
if (!$this->requiresPjax()) {
$this->registerClientScript();
return;
}
$view = $this->getView();
$view->endBody();
$view->endPage(true);
}
$content = ob_get_clean();
if ($requiresPjax) {
// only need the content enclosed within this widget
$response = Yii::$app->getResponse();
$level = ob_get_level();
......@@ -131,10 +136,6 @@ class Pjax extends Widget
ob_start();
ob_implicit_flush(false);
}
} else {
$this->registerClientScript();
echo $content;
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment