ajax chosen doesn't display search field if result < n

425 views
Skip to first unread message

Viper

unread,
Jun 3, 2013, 9:28:55 AM6/3/13
to joomla-de...@googlegroups.com
Example:
we have a "list" field with 1 predefined value. All other values must be search via ajax. Ok, no problem. It's work. But search field not showing up.
On the screenshot this is first field.

This is bug? If no, when the "ajax chosen" looks like not like ajax.

piotr_cz

unread,
Jun 3, 2013, 10:21:04 AM6/3/13
to Joomla! General Development
I don't think 'Chosen' supports Ajax by itself.

Take a look at the source code for <select /> element for that field
(this is being decorated by Chosen).
I'd say there is only 1 option to select from.

If this is the case, you should supply all options, but preselect one
by using 'default' field attribute
> <https://lh6.googleusercontent.com/-rmud_7bc6dY/UayZYJoNtBI/AAAAAAAAAD...>

Viper

unread,
Jun 3, 2013, 10:45:40 AM6/3/13
to joomla-de...@googlegroups.com
Yes. By default Chosen have no ajax support, but in media/jui/js/ we can see the ajax-chosen.js file that implements the ajax feature.
"you should supply all options" this is bad idea for me, 'cause result list contain more than 200 items.

Maybe I should use the type "text" instead of "list" in the field type?

piotr_cz

unread,
Jun 3, 2013, 4:43:03 PM6/3/13
to Joomla! General Development
You are correct - Ajax-chosen has been added to Joomla 3.1. I'm not a
friend with chosen.js and jQuery, I can't help you here.

Did you consider maybe using Typeahead with ajax?
http://twitter.github.io/bootstrap/javascript.html#typeahead

AJH

unread,
Feb 23, 2014, 3:11:56 PM2/23/14
to joomla-de...@googlegroups.com
It's not really a bug, but a hard-coded limit that someone decided.  The source of your problem lives in /libraries/cms/html/formbehavior.php

The function "chosen" in that file is hard-coding the 'disable_search_threshold' property to 10.

So you can do one of two things.
1) Live with the implementation and add 10 fake options to your control
2) Copy the content of the above mentioned file into your own component's HTML helper and adjust the content as needed.  That's what I did and it works great.

Fedir

unread,
Feb 24, 2014, 4:16:01 AM2/24/14
to joomla-de...@googlegroups.com
as I understand there is limit, and AJAX starts after >3 letter :)
so you need enter the word with at least 4 letters

Понеділок, 3 червня 2013 р. 16:28:55 UTC+3 користувач Viper написав:

Bakual

unread,
Feb 24, 2014, 8:44:33 AM2/24/14
to joomla-de...@googlegroups.com
A third option would of course be to propose some code to the CMS which would add a parameter to set that limit :)

Matt Thomas

unread,
Feb 24, 2014, 8:56:06 AM2/24/14
to Joomla! General Development
Or an option to completely disable it ;-) 

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages