Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 50d1fa3

Browse files
committed
Correct AjaxRenderer when not using fromSource but withOption('ajax', {...}) - #37
1 parent 8629234 commit 50d1fa3

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

dist/angular-datatables.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
if (angular.isDefined(options.fnPromise) && options.fnPromise !== null) {
353353
return new PromiseRenderer(options);
354354
}
355-
if (angular.isDefined(options.sAjaxSource) && options.sAjaxSource !== null) {
355+
if (angular.isDefined(options.sAjaxSource) && options.sAjaxSource !== null || options.ajax !== null) {
356356
return new AjaxRenderer(options);
357357
}
358358
return new DefaultRenderer(options);
@@ -484,7 +484,8 @@
484484
oTable.fnReloadAjax(options.sAjaxSource);
485485
} else if (!_isDTOldVersion(oTable)) {
486486
// For DataTable v1.10+, DT provides methods https://datatables.net/reference/api/ajax.url()
487-
oTable.ajax.url(options.sAjaxSource).load();
487+
var ajaxUrl = options.sAjaxSource || options.ajax.url || options.ajax;
488+
oTable.ajax.url(ajaxUrl).load();
488489
} else {
489490
throw new Error('Reload Ajax not supported. Please use the plugin "fnReloadAjax" (https://next.datatables.net/plug-ins/api/fnReloadAjax) or use a more recent version of DataTables (v1.10+)');
490491
}
@@ -505,8 +506,16 @@
505506
_this.options.aoColumns = DT_DEFAULT_OPTIONS.aoColumns;
506507
}
507508
$scope.$watch('dtOptions.sAjaxSource', function (sAjaxSource) {
508-
_this.options.sAjaxSource = sAjaxSource;
509-
_this.options.ajax = sAjaxSource;
509+
if (angular.isDefined(sAjaxSource)) {
510+
_this.options.sAjaxSource = sAjaxSource;
511+
if (angular.isDefined(_this.options.ajax)) {
512+
if (angular.isObject(_this.options.ajax)) {
513+
_this.options.ajax.url = sAjaxSource;
514+
} else {
515+
_this.options.ajax = { url: sAjaxSource };
516+
}
517+
}
518+
}
510519
_render(options, $elem, $scope);
511520
});
512521
$scope.$watch('dtOptions.reload', function (reload) {

0 commit comments

Comments
 (0)