|
|
|
@ -181,15 +181,18 @@ class Pjax extends Widget
|
|
|
|
|
$this->clientOptions['replace'] = $this->enableReplaceState; |
|
|
|
|
$this->clientOptions['timeout'] = $this->timeout; |
|
|
|
|
$this->clientOptions['scrollTo'] = $this->scrollTo; |
|
|
|
|
if(!isset($this->clientOptions['container'])) { |
|
|
|
|
$this->clientOptions['container'] = "#$id"; |
|
|
|
|
} |
|
|
|
|
$options = Json::htmlEncode($this->clientOptions); |
|
|
|
|
$js = ''; |
|
|
|
|
if ($this->linkSelector !== false) { |
|
|
|
|
$linkSelector = Json::htmlEncode($this->linkSelector !== null ? $this->linkSelector : '#' . $id . ' a'); |
|
|
|
|
$js .= "jQuery(document).pjax($linkSelector, \"#$id\", $options);"; |
|
|
|
|
$js .= "jQuery(document).pjax($linkSelector, $options);"; |
|
|
|
|
} |
|
|
|
|
if ($this->formSelector !== false) { |
|
|
|
|
$formSelector = Json::htmlEncode($this->formSelector !== null ? $this->formSelector : '#' . $id . ' form[data-pjax]'); |
|
|
|
|
$js .= "\njQuery(document).on('submit', $formSelector, function (event) {jQuery.pjax.submit(event, '#$id', $options);});"; |
|
|
|
|
$js .= "\njQuery(document).on('submit', $formSelector, function (event) {jQuery.pjax.submit(event, $options);});"; |
|
|
|
|
} |
|
|
|
|
$view = $this->getView(); |
|
|
|
|
PjaxAsset::register($view); |
|
|
|
|