Fixes #11850: Introduced yii\widgets\Pjax::$submitEvent to be able to customize event triggering PJAX form submit

This commit is contained in:
Bob van Leeuwen
2016-06-29 18:47:17 +02:00
committed by Alexander Makarov
parent 84ef97e8d9
commit 1dc688e35f
2 changed files with 8 additions and 1 deletions

View File

@ -42,6 +42,7 @@ Yii Framework 2 Change Log
- Bug #11561: Fixed DI container throwing exceptions for optional dependencies (SamMousa)
- Enh #11168: `yii\helpers\BaseHtml` now uses abstracted `booleanInput()` and `activeBooleanInput()` methods to render `radio()`, `checkbox()`, `activeRadio()` and `activeCheckbox()` (cesarnicola)
- Bug #11822: Fixed exception on non-string value provided as CSRF token (cebe)
- Enh #11850: Introduced `yii\widgets\Pjax::$submitEvent` to be able to customize event triggering PJAX form submit (Bvanleeuwen)
2.0.8 April 28, 2016
--------------------

View File

@ -67,6 +67,11 @@ class Pjax extends Widget
* Note that if the response to the pjax request is a full page, a normal request will be sent again.
*/
public $formSelector;
/**
* @var string The jQuery event that will trigger form handler. Defaults to "submit".
* @since 2.0.9
*/
public $submitEvent = 'submit';
/**
* @var boolean whether to enable push state.
*/
@ -189,7 +194,8 @@ class Pjax extends Widget
}
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);});";
$submitEvent = Json::htmlEncode($this->submitEvent);
$js .= "\njQuery(document).on('$submitEvent', $formSelector, function (event) {jQuery.pjax.submit(event, '#$id', $options);});";
}
$view = $this->getView();
PjaxAsset::register($view);