datatable refresh prb when source is in CrLf instead of Lf :

* add a try/catch block in the JS code
* properly escape string returned
This can happen for example when checking out with git-svn on Windows with core.autocrlf=auto

SVN:trunk[5089]
This commit is contained in:
Pierre Goiffon
2017-10-26 08:58:23 +00:00
parent b8ef2e68ba
commit e66eb537d8
2 changed files with 14 additions and 4 deletions

View File

@@ -606,7 +606,7 @@ EOF
$iPageSize = ($iDefaultPageSize < 1) ? 1 : $iDefaultPageSize;
$iPageIndex = 1 + floor($iStart / $iPageSize);
$sHtml = $this->GetPager($oPage, $iPageSize, $iDefaultPageSize, $iPageIndex);
$oPage->add_ready_script("$('#pager{$this->iListId}').html('".str_replace("\n", ' ', addslashes($sHtml))."');");
$oPage->add_ready_script("$('#pager{$this->iListId}').html('".json_encode($sHtml)."');");
if ($iDefaultPageSize < 1)
{
$oPage->add_ready_script("$('#pager{$this->iListId}').parent().hide()");

View File

@@ -91,9 +91,19 @@ $(function()
}
// End of workaround
me.element.find('.datacontents').html(data);
// restore the sort order on columns
me.element.find('table.listResults').trigger('fakesorton', [aCurrentSort]);
try {
me.element.find('.datacontents').html(data);
// restore the sort order on columns
me.element.find('table.listResults').trigger('fakesorton', [aCurrentSort]);
} catch (e) {
// ugly hacks for IE 8/9 first...
if (!window.console) console.error = {};
if (!window.console.error) {
console.error = function () {
};
}
console.error("Can not inject data : "+data);
}
me.element.unblock();
}, 'html' );