Browse Source

Fix Pjax container

If we set client option "container", it will be ignored, because param "container" of function always set.
tags/2.0.10
h0ckeypl4yer 9 years ago
parent
commit
10a2954d13
  1. 7
      framework/widgets/Pjax.php

7
framework/widgets/Pjax.php

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

Loading…
Cancel
Save