Skip to content
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

Option to limit the number of selected items at the js level #96

Open
mlavin opened this issue Nov 10, 2013 · 1 comment
Open

Option to limit the number of selected items at the js level #96

mlavin opened this issue Nov 10, 2013 · 1 comment

Comments

@mlavin
Copy link
Owner

mlavin commented Nov 10, 2013

Hi Mark,
Can we get the client-side ability to limit the number of items that can be selected via AutoCompleteSelectMultipleWidget? I'm guessing that an option like this would help enforce proper usage in many web applications. For my usecase, it's how many dances a user can claim as his/her specialty.

It would be very convenient to be able to set this limit when declaring the widget or AutoCompleteSelectMultipleField in python and have that option relayed to the javascript.

Let me know if this is something you'd like to see implemented. I may have some time available next week.


@mlavin
Copy link
Owner Author

mlavin commented Nov 10, 2013

While there isn't an option in the JS plugin that you could pass from the widget, it is currently possible to limit the number of items added on the client-side using the djselectableadd and djselectableremove events and returning false in the event handler. https://django-selectable.readthedocs.org/en/version-0.6.2/advanced.html#detecting-client-side-changes

Still this would need to be validated on the server-side which would have to fall to the field or the form rather than the widget which starts to creep out of scope for the project. But if you come up with something simple that you think would be helpful for most people then I'd love to see it.


Original Comment By: Mark Lavin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant