Skip to content

Commit

Permalink
Fixed issue #12815: Error after multiple question deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Jan 25, 2018
1 parent a7388ab commit 3af3bd0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
13 changes: 13 additions & 0 deletions application/core/LSYii_ClientScript.php
Expand Up @@ -32,6 +32,7 @@ class LSYii_ClientScript extends CClientScript
{

const POS_POSTSCRIPT = 5;
const POS_PREBEGIN = 6;
/**
* cssFiles is protected on CClientScript. It can be useful to access it for debugin purpose
* @return array
Expand Down Expand Up @@ -448,6 +449,18 @@ public function renderBodyBegin(&$output)
{
$html = '';

if (isset($this->scriptFiles[self::POS_PREBEGIN])) {
foreach ($this->scriptFiles[self::POS_PREBEGIN] as $scriptFileUrl=>$scriptFileValue) {
if (is_array($scriptFileValue)) {
$html .= CHtml::scriptFile($scriptFileUrl, $scriptFileValue)."\n";
} else {
$html .= CHtml::scriptFile($scriptFileUrl)."\n";
}
}
}
if (isset($this->scripts[self::POS_PREBEGIN])) {
$html .= $this->renderScriptBatch($this->scripts[self::POS_PREBEGIN]);
}
if (isset($this->scriptFiles[self::POS_BEGIN])) {
foreach ($this->scriptFiles[self::POS_BEGIN] as $scriptFileUrl=>$scriptFileValue) {
if (is_array($scriptFileValue)) {
Expand Down
8 changes: 4 additions & 4 deletions application/views/admin/survey/Question/listquestions.php
Expand Up @@ -147,7 +147,7 @@
array('class'=>'changePageSize form-control', 'style'=>'display: inline; width: auto'))),
'columns' => $columns,
'ajaxUpdate' => true,
'afterAjaxUpdate' => 'bindPageSizeChange'
'afterAjaxUpdate' => "bindPageSizeChange"
));
?>
</div>
Expand Down Expand Up @@ -178,12 +178,12 @@

<!-- To update rows per page via ajax -->
<?php App()->getClientScript()->registerScript("ListQuestions-pagination", "
var bindPageSizeChange = function(){
function bindPageSizeChange(){
$('#pageSize').on('change', function(){
$.fn.yiiGridView.update('question-grid',{ data:{ pageSize: $(this).val() }});
$('#question-grid').yiiGridView('update',{ data:{ pageSize: $(this).val() }});
});
$(document).trigger('actions-updated');
};
", LSYii_ClientScript::POS_BEGIN); ?>

<?php App()->getClientScript()->registerScript("ListQuestions-run-pagination", "bindPageSizeChange(); ", LSYii_ClientScript::POS_POSTSCRIPT); ?>
<?php App()->getClientScript()->registerScript("ListQuestions-run-pagination", "bindPageSizeChange();", LSYii_ClientScript::POS_POSTSCRIPT); ?>
1 change: 1 addition & 0 deletions framework/web/js/packages.php
Expand Up @@ -68,6 +68,7 @@
'depends'=>array('jquery'),
),
'bbq'=>array(
'position' => CClientScript::POS_BEGIN,
'js'=>array(YII_DEBUG ? 'jquery.ba-bbq.js' : 'jquery.ba-bbq.min.js'),
'depends'=>array('jquery'),
),
Expand Down
4 changes: 2 additions & 2 deletions framework/zii/widgets/grid/CGridView.php
Expand Up @@ -472,8 +472,8 @@ public function registerClientScript()
$cs->registerCoreScript('bbq');
if($this->enableHistory)
$cs->registerCoreScript('history');
$cs->registerScriptFile($this->baseScriptUrl.'/jquery.yiigridview.js',CClientScript::POS_END);
$cs->registerScript(__CLASS__.'#'.$id,"jQuery('#$id').yiiGridView($options);");
$cs->registerScriptFile($this->baseScriptUrl.'/jquery.yiigridview.js',LSYii_ClientScript::POS_PREBEGIN);
$cs->registerScript(__CLASS__.'#'.$id,"jQuery('#$id').yiiGridView($options);",LSYii_ClientScript::POS_POSTSCRIPT);
}

/**
Expand Down

0 comments on commit 3af3bd0

Please sign in to comment.