Browse Source

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

tags/2.0.0-beta
Paul Klimov 11 years ago
parent
commit
04f381eba0
  1. 1129
      framework/assets/pjax/jquery.pjax.js
  2. 10
      framework/widgets/Pjax.php

1129
framework/assets/pjax/jquery.pjax.js

File diff suppressed because it is too large Load Diff

10
framework/widgets/Pjax.php

@ -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);
}
}

Loading…
Cancel
Save