Skip to content

Commit b2d6538

Browse files
committed
Add drawCallbackWithLivewire api.
Solution as per issue yajra/laravel-datatables#2401.
1 parent 925f6c6 commit b2d6538

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Html/Options/HasCallbacks.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@ public function drawCallback($script)
3737
return $this;
3838
}
3939

40+
/**
41+
* Set drawCallback option value with Livewire integration.
42+
* Solution as per issue https://github.com/yajra/laravel-datatables/issues/2401.
43+
*
44+
* @param mixed|null $script
45+
* @return $this
46+
* @see https://datatables.net/reference/option/drawCallback
47+
*/
48+
public function drawCallbackWithLivewire($script = null)
49+
{
50+
$js = "function(settings) {
51+
if (window.livewire) {
52+
window.livewire.rescan();
53+
}
54+
55+
$script
56+
}";
57+
58+
$this->attributes['drawCallback'] = $js;
59+
60+
return $this;
61+
}
62+
4063
/**
4164
* Set footerCallback option value.
4265
*

0 commit comments

Comments
 (0)