Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork69
Wait for DOM before executing script.#133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
yajra commentedSep 24, 2020
I actually did something same few weeks ago and wrap the script with document ready of jQuery but it seems to break some scripts. I think your solution is better, will give this a try as soon as I can. Thanks! |
yajra commentedOct 1, 2020
Not an expert on js but some posts online states that DOMContentLoaded is not supported on some browsers and jQuery ready is the equivalent and a safer way to do it? Do you think we should use jQuery.ready instead of DOMContentLoaded? $(function(){window.LaravelDataTables=window.LaravelDataTables||{};window.LaravelDataTables["%1$s"]=$("#%1$s").DataTable(%2$s);}); That is also what I used on my custom editor.blade.php script and seems to work fine. Also fixes an issue with bfcache of chrome. $(function(){$.ajaxSetup({headers: {'X-CSRF-TOKEN':'{{csrf_token()}}'}}); @foreach($editors as $editor) var {{$editor->instance}} = window.LaravelDataTables["%1$s-{{$editor->instance}}"] = new $.fn.dataTable.Editor({!! $editor->toJson() !!}); {!! $editor->scripts !!} @foreach ((array) $editor->events as $event) {{$editor->instance}}.on('{!!$event['event'] !!}', {!!$event['script'] !!}); @endforeach @endforeach window.LaravelDataTables["%1$s"] =$("#%1$s").DataTable(%2$s);}); |
No description provided.