trco / django-bootstrap-modal-forms

A Django plugin for creating AJAX driven forms in Bootstrap modal.
MIT License
383 stars 139 forks source link

Libraries order issue with django-adminlte3 #153

Closed mbacicc closed 1 year ago

mbacicc commented 3 years ago

I'm stuck with the problem related to the order of jQuery and Bootstrap. My problem is that I run into the error Uncaught TypeError: $(...).modalForm is not a function I'm working with django-adminlte3, which loads the libraries in such order: <script src="{% static 'admin-lte/plugins/jquery/jquery.min.js' %}"></script> <script src="{% static 'admin-lte/plugins/jquery-ui/jquery-ui.min.js' %}"></script> <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip --> ... <script src="{% static 'admin-lte/plugins/bootstrap/js/bootstrap.bundle.min.js' %} "></script> If I move bootstrap before jQuery, I obtain this error: Uncaught TypeError: Bootstrap's JavaScript requires jQuery. jQuery must be included before Bootstrap's JavaScript. I don't see a solution to this problem.

I also want to notify a problem that I solved by importing the code from the example with recent version of Django: function addModelSyncModalForm() { $("#add-model").modalForm({ formURL: "{% url 'app_name:view_name_from_urls' %}", // important to add <app name>:<view name> and not just the view name modalID: "#modal-model" }); } addModelSyncModalForm();

trco commented 3 years ago

@mbacicc Uncaught TypeError: $(...).modalForm is not a function error means that you didn't load django-bootstrap-modal forms js properly. See Installation section in readme https://github.com/trco/django-bootstrap-modal-forms#installation.

I would say that the problem with view name you're describing is not a problem at all. If you define app_name for the apps in your project you should use app_name:view_name to link to the proper view. This is default Django behaviour.

infosrabah commented 3 years ago

Just to let everyone know that I had like a similar problem, I change a templae admin for another one and took off jquery-slim and replace it with a recent version of jQuery (in the new admin template) All work great now, But I thins allso that not every admin template out their played nice with the project.

Hope it helps.

thank you

trco commented 1 year ago

Closing the issue. In case of reopening please provide clear reproduce, optimally by creating public repo with the issue.