Commit 04f381eb by Paul Klimov

Merge branch 'master' of github.com:yiisoft/yii2

parents 518954da afefcd6e
......@@ -50,10 +50,16 @@ class Pjax extends Widget
/**
* @var string the jQuery selector of the links that should trigger pjax requests.
* If not set, all links within the enclosed content of Pjax will trigger pjax requests.
* Note that the pjax response to a link is a full page, a normal request will be sent again.
* Note that if the response to the pjax request is a full page, a normal request will be sent again.
*/
public $linkSelector;
/**
* @var string the jQuery selector of the forms whose submissions should trigger pjax requests.
* If not set, all forms with `data-pjax` attribute within the enclosed content of Pjax will trigger pjax requests.
* Note that if the response to the pjax request is a full page, a normal request will be sent again.
*/
public $formSelector;
/**
* @var boolean whether to enable push state.
*/
public $enablePushState = true;
......@@ -148,9 +154,11 @@ class Pjax extends Widget
$this->clientOptions['timeout'] = $this->timeout;
$options = Json::encode($this->clientOptions);
$linkSelector = Json::encode($this->linkSelector !== null ? $this->linkSelector : '#' . $id . ' a');
$formSelector = Json::encode($this->formSelector !== null ? $this->formSelector : '#' . $id . ' form[data-pjax]');
$view = $this->getView();
PjaxAsset::register($view);
$js = "jQuery(document).pjax($linkSelector, \"#$id\", $options);";
$js .= "jQuery(document).on('submit', $formSelector, function (event) {jQuery.pjax.submit(event, '#$id');});";
$view->registerJs($js);
}
}
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