What decided when a script (chosen.js) is loaded in the head?

22 views
Skip to first unread message

Marvin_Martiano

unread,
Nov 23, 2017, 6:37:54 PM11/23/17
to Joomla! General Development
Possibly an obtuse question, but:

In my profile plugin, I have an obligatory dropdown for country. When logged on and looking at the profile, this is nicely calling chosen.min.js as well as chosen.css --- but chosen.js isn't called on the registration page (which makes the dropdown both ugly and glitchy in my case). And other pages without dropdowns (correctly) aren't loading it either.

[This is mostly a problem on FireFox, because the non-Chosen dropdown works well on e.g. Chrome and Safari; but any number of not-yet-tested browsers may be a problem.]

So, what's the big difference between edit-profile.php and registration.php that the one triggers inclusion chosen.js and the other doesn't? Or between their default.php templates? Or am I looking in totally the wrong corner -- has it something to do with a lack of initial value not triggering on the registration page?

All the best,
M

Michael Babker

unread,
Nov 23, 2017, 6:50:06 PM11/23/17
to joomla-de...@googlegroups.com
You're missing a call to JHtml::_('formbehavior.chosen');

If your script relies on Chosen being loaded, you should call that to ensure it is loaded versus relying on other parts of the system to do it for you.

--
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-general+unsub...@googlegroups.com.
To post to this group, send email to joomla-dev-general@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

Marvin_Martiano

unread,
Nov 24, 2017, 5:21:26 AM11/24/17
to Joomla! General Development
Thanks so much! That was indeed it, it worked immediately with:  JHtml::_('formbehavior.chosen', 'select');

I had been searching in the wrong place and gave up before posting: I thought the "head"-php was inserting the scripts, so searched through that code and didn't see it; then searching for "chosen.js" across the joomla filesystem gave only two matches, while "chosen" I stopped after 800+ were found... Then GREP for "chosen" and "js" on the same line also no dice. I stupidly kept looking for "chosen"+"js" in all the files I had touched...

 If I'd just searched "chosen" alone, I would have found the line in my template's override of the profile editing view but not the registration view...

Actually, should I submit this as a possible bug: The default com_users/views has in /profile/tmpl/edit.php the "formbehavior.chosen"-line, but /registration/tmpl/default.php does not. I'd think either both or neither should have this line included? Most other differences between the two are cosmetic, plus /edit.php allows two-factor authentication, but only one of the two checks the user's language.

Thanks again,
M
Reply all
Reply to author
Forward
0 new messages