omines / datatables-bundle

DataTables bundle for Symfony
https://omines.github.io/datatables-bundle/
MIT License
262 stars 114 forks source link

Uncaught TypeError: $(...).initDataTables is not a function #144

Closed virtualmayur closed 4 years ago

virtualmayur commented 4 years ago

HI @curry684, @jaztec, @freezy-sk, @biji , @michaelotoole can anyone of you help me in this. I am using symfony 5 and PHP 7.4 already run command to copy datatables.js into public folder, the file is called but getting the same error always. Is there any solution for this.

 <script type="text/javascript" src="{{ asset('/bundles/datatables/js/datatables.js') }}"></script>
    <script>
        $(function() {
            $('#presidents').initDataTables({{ datatable_settings(datatable) }});
        });
    </script>

put it at the end of file before body block from the controller sending the following code.

 $table = $dataTableFactory->create()
            ->add('firstName', TextColumn::class)
            ->add('lastName', TextColumn::class)
            ->createAdapter(ArrayAdapter::class, [
                ['firstName' => 'Donald', 'lastName' => 'Trump'],
                ['firstName' => 'Barack', 'lastName' => 'Obama'],
            ])->handleRequest($request);
curry684 commented 4 years ago

Please do not highlight a ton of very busy people without good reason, we're not your private consultancy firm.

Also please read the Support section of the README.md.

freezy-sk commented 4 years ago

@virtualmayur I can give you small hint. when you copy-paste some code from documentation and modify it after that, try if the same error occurs without you modifications.

https://omines.github.io/datatables-bundle/#frontend-code

<!-- Insert this at the end of your body element, but before the closing tag -->
<script src="{{ asset('bundles/datatables/js/datatables.js') }}"></script>
<script>
$(function() {
    $('#presidents').initDataTables({{ datatable_settings(datatable) }});
});
</script>