Skip to content

Commit 4cc0487

Browse files
committed
Merge branch 'master' of github.com:omines/datatables-bundle
2 parents 229229a + 351227d commit 4cc0487

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Build Status](https://travis-ci.org/omines/datatables-bundle.svg?branch=master)](https://travis-ci.org/omines/datatables-bundle)
77
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/omines/datatables-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/omines/datatables-bundle/?branch=master)
88
[![Code Coverage](https://scrutinizer-ci.com/g/omines/datatables-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/omines/datatables-bundle/?branch=master)
9-
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/05d79ba2-cba4-4201-a17a-2868c51f9c6c.svg)](https://insight.sensiolabs.com/projects/05d79ba2-cba4-4201-a17a-2868c51f9c6c)
9+
[![SymfonyInsight](https://img.shields.io/symfony/i/grade/05d79ba2-cba4-4201-a17a-2868c51f9c6c)](https://insight.symfony.com/projects/05d79ba2-cba4-4201-a17a-2868c51f9c6c)
1010

1111
This bundle provides convenient integration of the popular [DataTables](https://datatables.net/) jQuery library
1212
for realtime Ajax tables in your [Symfony](https://symfony.com/) 4.1+ or 5.0+ application.

src/Resources/public/js/datatables.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
return new Promise((fulfill, reject) => {
4444
// Perform initial load
45-
$.ajax(config.url, {
45+
$.ajax(typeof config.url === 'function' ? config.url(null) : config.url, {
4646
method: config.method,
4747
data: {
4848
_dt: config.name,
@@ -52,7 +52,7 @@
5252
var baseState;
5353

5454
// Merge all options from different sources together and add the Ajax loader
55-
var dtOpts = $.extend({}, data.options, config.options, options, persistOptions, {
55+
var dtOpts = $.extend({}, data.options, typeof config.options === 'function' ? {} : config.options, options, persistOptions, {
5656
ajax: function (request, drawCallback, settings) {
5757
if (data) {
5858
data.draw = request.draw;
@@ -71,7 +71,7 @@
7171
}
7272
} else {
7373
request._dt = config.name;
74-
$.ajax(config.url, {
74+
$.ajax(typeof config.url === 'function' ? config.url(dt) : config.url, {
7575
method: config.method,
7676
data: request
7777
}).done(function(data) {
@@ -81,6 +81,10 @@
8181
}
8282
});
8383

84+
if (typeof config.options === 'function') {
85+
dtOpts = config.options(dtOpts);
86+
}
87+
8488
root.html(data.template);
8589
dt = $('table', root).DataTable(dtOpts);
8690
if (config.state !== 'none') {

0 commit comments

Comments
 (0)