advice for adding "select all" feature extension to AutoComboBoxSelectMultipleWidget

20 views
Skip to first unread message

dan garfield

unread,
Nov 27, 2012, 3:40:41 PM11/27/12
to django-s...@googlegroups.com
Hi Mark,

I have been trying to extend the select multiple combo box to support the case of a user wanting to add all of the results returned by the autocomplete query in a single click. I spent a few hours today trying to set up some jQuery event handlers to trigger click events on each item in the result list. I have discovered, unfortunately, that this doesn't seem to be possible due to event order of execution problems that I don't seem to be able to work around. I am able to get the first item only to process its click event, but this seems like it immediately triggers a blur that prevents execution of the click on the rest of the items in the result set. 

Do you have any idea about a better way to do what I'm trying to do? Is there a good solution to the event timing issues? Is there a way to access item selection without using click events? 

Thanks in advance for any help you might be able to provide. I've so far enjoyed working with django-selectable and would like to learn how to effectively extend it in this way. If I manage to come up with a good solution I would love to contribute it back to the project so others can benefit as well. 

Regards,

Dan Garfield

Mark Lavin

unread,
Nov 27, 2012, 4:13:48 PM11/27/12
to django-s...@googlegroups.com
Dan,

That's an interesting use-case. You can manually trigger the item selection without the click with

$('#id_of_field').djselectable('select', {'id': myid, 'value': myvalue});

There was another person who asked about this for a different use https://groups.google.com/d/msg/django-selectable/q2iQco8Jrkw/vTA39HuRMjgJ and it's used internally for the admin customization.

I don't have an brilliant insights on how to accomplish what you are trying to do off the top of my head but I would be interested in see what you can get working. If you have some other questions or run into other problems I'm happy to chime in.

Best,

Mark
Reply all
Reply to author
Forward
0 new messages