public function init() { if (Yii::$app->request->isPjax) { $id = Yii::$app->request->headers->get('X-PJAX-Container'); if ($id) { $this->id = substr($id, 1); $this->_pjax = Pjax::begin(ArrayHelper::merge(['id' => $this->getId(), 'linkSelector' => false, 'formSelector' => false, 'enablePushState' => false, 'enableReplaceState' => false], $this->pjaxOptions)); $this->_pjax->registerClientScript(); } } parent::init(); }
public function registerClientScript() { parent::registerClientScript(); $this->getView()->registerJs(' var pjaxLoader_' . $this->getSanitizedId() . ' = "' . addslashes($this->loader) . '"; jQuery(document).on("pjax:start", "#' . $this->options['id'] . '", function() { jQuery("#' . $this->options['id'] . '").append(pjaxLoader_' . $this->getSanitizedId() . '); }); '); }
/** * Registers the needed JavaScript. */ public function registerClientScript() { parent::registerClientScript(); $errorMessage = \Yii::t('skeeks/admin', 'An unexpected error occurred. Refer to the developers.'); if ($this->isBlock === true) { $this->getView()->registerJs(<<<JS (function(sx, \$, _) { var blockerPanel = new sx.classes.Blocker('.sx-panel'); \$(document).on('pjax:send', function(e) { blockerPanel = new sx.classes.Blocker(\$(e.target)); blockerPanel.block(); }); \$(document).on('pjax:complete', function(e) { blockerPanel.unblock(); }); \$(document).on('pjax:error', function(e, data) { sx.notify.error('{$errorMessage}'); blockerPanel.unblock(); }); })(sx, sx.\$, sx._); JS ); } if ($this->blockContainer) { $this->getView()->registerJs(<<<JS (function(sx, \$, _) { var blockerPanel = new sx.classes.Blocker(\$("{$this->blockContainer}")); \$(document).on('pjax:send', function(e) { var blockerPanel = new sx.classes.Blocker(\$("{$this->blockContainer}")); blockerPanel.block(); }); \$(document).on('pjax:complete', function(e) { blockerPanel.unblock(); }); \$(document).on('pjax:error', function(e, data) { sx.notify.error('{$errorMessage}'); blockerPanel.unblock(); }); })(sx, sx.\$, sx._); JS ); } }
/** * Registers the needed JavaScript. */ public function registerClientScript() { parent::registerClientScript(); if ($this->blockPjaxContainer === true) { $this->getView()->registerJs(<<<JS (function(sx, \$, _) { var blockerPanel = new sx.classes.Blocker('.sx-panel'); \$(document).on('pjax:send', function(e) { var blockerPanel = new sx.classes.Blocker(\$(e.target)); blockerPanel.block(); }) \$(document).on('pjax:complete', function(e) { blockerPanel.unblock(); }) })(sx, sx.\$, sx._); JS ); } if ($this->blockContainer) { $this->getView()->registerJs(<<<JS (function(sx, \$, _) { var blockerPanel = new sx.classes.Blocker(\$("{$this->blockContainer}")); \$(document).on('pjax:send', function(e) { var blockerPanel = new sx.classes.Blocker(\$("{$this->blockContainer}")); blockerPanel.block(); }) \$(document).on('pjax:complete', function(e) { blockerPanel.unblock(); }) })(sx, sx.\$, sx._); JS ); } }
public function registerClientScript() { $this->clientOptions['fragment'] = $this->options['id']; parent::registerClientScript(); }