Comments (11)
@bguerrero5 I don't know how django-select2 implements select2 but you could load select2 js and css, select your dropdown within the script living in your form's html and run .select2() on it.
<form method="post" action="">
{% csrf_token %}
<div class="modal-header">
...
</div>
<div class="modal-body">
{% for field in form %}
...
{% endfor %}
</div>
<div class="modal-footer">
...
</div>
</form>
<script type="text/javascript">
$(function () {
$(".your-class").select2();
});
</script>
from django-bootstrap-modal-forms.
Thank for the fast response @trco. It is still not working. I am not sure whats causing the problem. I am also using crispy froms. Do you think that could be the problem?
from django-bootstrap-modal-forms.
@bguerrero5 You should provide some error log or code so I can see what's happening. It's hard to debug on ''for some reason django-select2 drop down does not work''.
from django-bootstrap-modal-forms.
@trco well I am not getting any error with my interpreter. But, in the console at the browser developer tools i can see a couple of error with the java-script. Attached you can find some screenshots of this errors. The screenshots have been uploaded in the order they appear in the browser.
from django-bootstrap-modal-forms.
@bguerrero5 Is it possible that you didn't include select2 js and css files together with my proposed solution? You're calling select2 function on an element, but the function obviously doesn't exist.
from django-bootstrap-modal-forms.
@trco yeah, i am calling the select2 function. it looks like this. I am not really good with java-script but i believe it is right.
{% load static %}
{% load crispy_forms_tags %}
{{ title }}
×from django-bootstrap-modal-forms.
Sorry, here is a better screenshot.
from django-bootstrap-modal-forms.
@bguerrero5 You should load js and css for select2. Either download it to your static folder and link to it or link to select2 cdns as written in their docs.
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/js/select2.min.js"></script>
from django-bootstrap-modal-forms.
@trco when i load the js and ccs for select2, it still not works. But now i get a different error at the console.
from django-bootstrap-modal-forms.
@bguerrero5 Unfortunately I can't conclude anything from that. I still suggest you to try out select2 without django-select2. Load js and css and than instantiate select2 on fields you get by their ids.
from django-bootstrap-modal-forms.
Closing due to inactivity.
from django-bootstrap-modal-forms.
Related Issues (20)
- missing "database" folder
- Allow to send extra parameters in the POST request.
- Multiple submit buttons in modal
- Maintenance of the project HOT 9
- Automate JS Minify Process
- How to make a nested modal
- Undesired GET request when using a BSModalCreateView HOT 4
- Incorrect errorClass in documentation HOT 1
- Generic views don't respond to get_success_url() since version 3.0.0 HOT 5
- Delete view success message is shown although object not deleted HOT 1
- form validation object already exist error does not shown in modal after modal form submissin with crispy form within modal HOT 3
- Django Internal server error - widget_tweaks failed to parse render_field HOT 1
- Checkbox does not render correctly. HOT 3
- btnSubmit fails detection after html minification
- Double post when submitting modal form HOT 5
- Restrict users from directly accessing the form url HOT 1
- How to remove Click listener HOT 1
- Open a new modal with the current modal form's results
- Event listeners disappear after the form is invalid. HOT 1
- FormValidationMixin shadows setting of self.object (defined in BaseCreateView)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-bootstrap-modal-forms.