-
Notifications
You must be signed in to change notification settings - Fork 315
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new tag position #270
Comments
Update: I got it working by doing the following:
This worked, but is there a better way? |
You don't need to copy the JS file. It's possible to overwrite the default JS options. |
Thanks for replying. Are you saying that in my template I should override the initHeavy function, with the settings already listed in the django_select2.js file and adding the insertTag option? Or is there a way to pass in the insertTag code as an option to the initHeavy function? Sorry if I'm missing something obvious here... |
No you should overwrite |
Hmm, I tried overriding attrs['class'] when I instantiate my widget, but the normal django-select2 classes are still added to my custom class, and the regular init functions are still called. Would I need to override the widget build_attrs method as well? |
Yes, I just append the class in the |
Well, it seems like the user needs to be able to pass options into the javascript pretty easily, since there's this insertTag feature from select2 that has to be done in javascript. I see this line in django_select2.js, that's called automatically: It seems like if this line could have some options that default to empty, but that the user could pass things in as needed (without overriding that file completely), that would be nice. But I'm not exactly sure how to do this. One option would be to take out the $('.django-select2').djangoSelect2(); line and have the user put it in their template. That would add another step that everyone would need to do to use django-select2, but it would make it a lot easier to add custom javascript code, because you could just pass options through that call (without needing to override that file completely). Even better would be if you could call djangoSelect2() conditionally in django_select2.js - call it automatically if the user hasn't overridden it, but use the user's version if they have one in their template. Hopefully there's something helpful in these comments. |
Hm... good point. Regular options you can base as widget |
Closed: This issue has been inactive for an extended period of time. Please reopen the issue if it is still relevant. |
I would like to move the position of the new tag that the user's typing to the bottom of the list, instead of the top. That seems to be newly supported in select2 4.0.2 (select2/select2#4008). What's the best way to do this in django-select2?
The text was updated successfully, but these errors were encountered: