Hi everyone,
after upgrading to 6.x-1.4, I realized a JavaScript error preventing other scripts to load, took me a while to find the cause of this... it appears to be a 3x mistyped landDropdown instead of langDropdown. After changing that, the error was gone. I'm pretty new to all this bug reporting/fixing thing, but I'll try and attach my first patch, just for the sake of learning git... hope it is helpfull and the right way to do it.
--- modules/lang_dropdown/lang_dropdown.js
+++ modules/lang_dropdown/lang_dropdown.js
@@ -3,17 +3,17 @@ Drupal.behaviors.langDropdown = function(context) {
document.location.href = this.options[this.selectedIndex].value;
});
- if (Drupal.settings.landDropdown) {
- var flags = Drupal.settings.landDropdown.jsWidget.languageicons;
+ if (Drupal.settings.langDropdown) {
+ var flags = Drupal.settings.langDropdown.jsWidget.languageicons;
$.each(flags, function(index, value) {
$('#edit-lang-dropdown-select option[value=' + index + ']').attr('title', value);
});
- var msddSettings = Drupal.settings.landDropdown.jsWidget;
+ var msddSettings = Drupal.settings.langDropdown.jsWidget;
$('#edit-lang-dropdown-select').msDropDown({
visibleRows: msddSettings.visibleRows,
rowHeight: msddSettings.rowHeight,
animStyle: msddSettings.animStyle
});
}
-}
\ No newline at end of file
+}
Comments
Comment #1
manfer commentedlandDropdown is the name the module is using as can be seen in .module file, line 108.
Probably it is more logical langDropdown but if it is changed in lang_dropdown.js it must be changed too in that line in lang_dropdown.module.
Comment #2
mohammed j. razemFixed in release 6.x-1.5
Comment #3
kevinsiji commentedThe patch by user heliogabal fixed the problem in 6.x-1.4. The version 6.x-1.5 is still having the same problem. It seems the same problem (a JavaScript error preventing other scripts to load) crops up again in some other way. The js of module compact_forms & admin_menu fails when I enable 6.x-1.5 in my test site.
Comment #4
manfer commentedIf there is a js error, could you provide the error please?
The patch by heliogabal the only thing that does is disabling some js code because applying that patch, the module sets the variable to landDropdown in php, but js variable test for langDropdown after applying the patch -- if (Drupal.settings.langDropdown) --. As the variable is undefined then maybe that solves your issue because some of the js is not executed and the dropdown menu is presented as a normal select instead of using the drop down menu jquery library. But it won't be the solution.
So it would be of great help if the javascript error is provided as I think most people is not experimenting that problem.
As it seems heliogabal code solves it, that means the problem is on this lines of code:
Maybe this happens in sites with language switcher dropdown but not language icons module. Probably in such a situation flags is undefined and $.each(flags, ... will trigger an error.
I'm going to test that.
And maybe you can confirm if you don't have language icons installed on your sites.
Comment #5
manfer commentedChanging:
to:
will solve the issue I think.
Comment #6
heliogabalhi manfer,
thanks for looking into this. you are right, it seems to be the not used language icons. I can confirm that the error goes away using the if-flags you propose. I'm glad my quick shot did at least help cornering the problem...
The JS Error showing in chrome was:
Uncaught TypeError: Cannot read property 'length' of undefined
D.extend.each:1
Drupal.behaviors.langDropdown modules/lang_dropdown/lang_dropdown.js?F:8
Line 8:
(anonymous function) misc/drupal.js?F:42
D.extend.each:1
Drupal.attachBehaviors misc/drupal.js?F:41
Drupal.theme.placeholder misc/drupal.js?F:277
D.fn.extend.ready:1
D.extend.ready.D.readyList:1
D.extend.each:1
D.extend.ready
Failed to load resource
Comment #7
mohammed j. razemThanks for the patch. New release 6.x-1.6 fixed this.