How to customize autocomplete-light Javascript

321 views
Skip to first unread message

Jonas H.

unread,
Apr 5, 2013, 1:05:08 PM4/5/13
to your...@googlegroups.com
First off: This tool is awesome. I've rarely seen software of this type
with such exceptionally high code quality. Thanks for that!

Back to topic: On suggestion click, I'd like to not hide the input box,
and do some custom foo based on the PK of the suggestion instead.

How can I achieve this? Connecting to the selectChoice signal?
Overriding the method in widget.js bound to that signal? Could someone
maybe show a small code sample?

Thanks a lot!
Jonas

Jonas H.

unread,
Apr 18, 2013, 2:06:55 PM4/18/13
to your...@googlegroups.com
*bump*

James Pic

unread,
Apr 19, 2013, 4:48:18 AM4/19/13
to your...@googlegroups.com
On Fri, Apr 5, 2013 at 7:05 PM, Jonas H. <jo...@lophus.org> wrote:
> First off: This tool is awesome. I've rarely seen software of this type with
> such exceptionally high code quality. Thanks for that!
>

Thanks !

> Back to topic: On suggestion click, I'd like to not hide the input box,

The input box hides when maxValues is reached. If maxValues=1 like in
the case of an FK then the input hides when one choice is selected.

> and
> do some custom foo based on the PK of the suggestion instead.
>
> How can I achieve this? Connecting to the selectChoice signal? Overriding
> the method in widget.js bound to that signal? Could someone maybe show a
> small code sample?
>

If you want to add a behaviour, then you could connect selectChoice or
to the change event of the hidden select:

- http://django-autocomplete-light.readthedocs.org/en/latest/tutorial.html#get-an-existing-autocomplete-object-and-chain-autocompletes
- http://django-autocomplete-light.readthedocs.org/en/latest/cookbook.html#low-level-basics

If you want to replace the default behaviour then you should override
the method.

http://django-autocomplete-light.readthedocs.org/en/latest/tutorial.html#overriding-widget-js-methods

Let me know if this doesn't answer your question.

> Thanks a lot!



--
http://yourlabs.org
Customer is king - Le client est roi - El cliente es rey.
Reply all
Reply to author
Forward
0 new messages