Hi!

I have just updated two of my website to Reponsive Dropdown Menus 7.x-1.1.

My website's menu has two levels. When viewed on a computer, the 2nd level is displayed when hovering the 1st level. On mobile devices the entire menu is displayed when the toggle is clicked.

Everything is working fine, except on the front page. When viewed on a computer, the 2nd level isn't displayed at all. On mobile devices, the menu toggle is missing alltogether. Again, this happens only on the front page.

I noticed that the responsive-dropdown-menus.js is not loaded on the front page. I tried adding it in the template.php file, but this didn't fix it for me.

When I reverted back to version 7.x-1.0 everything was back to normal again.

Thank you!

CommentFileSizeAuthor
#8 js_not_loaded_on_front-2472977-7.patch1.52 KBmglaman

Comments

mglaman’s picture

Priority: Normal » Major

That is super odd! In 1.1 I moved to #attached and not drupal_add_css() in page build. Apparently that isn't working as expected!

As a work around, you can manually recreate the drupal_add_CSS() find in 1.0.

sylv3st3r’s picture

Happen to me too. Using 1.0 method for page build didn't work for me. I have to force attached the js from my theme info then commenting js attach from the module altogether to make it work.
I believe it works before, then suddenly it's missing from front page. Still dunno why

crystaldawn’s picture

Priority: Major » Critical

The proposed fix of adding the JS/css via drupal_add_js/css does not seem to work at all. It results in: Uncaught TypeError: Cannot read property 'length' of undefined. No amount of commenting the "attached" lines combined with add_js/css works. It appears to be a jQuery conflict of some sort possibly due to ordering of the JS maybe? Not sure but this is pretty critical so I've marked it as such since it renders this module useless.

Thus it never functions as expected. It works fine on sub pages, but never on the front page (which sorta defeats the purpose of having a menu on the front page right? lol)

mglaman’s picture

I'll be visiting this tomorrow, sorry for delays. Don't do as much client/front-end work anymore so not dealing with this as often!

crystaldawn’s picture

BTW when I mention front page, this means that the template page--front.tpl.php is being used. For whatever reason, drupal does not seem to actually process the "#attached" lines. To discover this I added a hook_preprocess_page($vars) to the template.php and simply print the output of the page element. I could see that the js and css ARE there, but if you look at the source html of the front page, it does not actually add the css/js to the drupal jquery like it does with the sub pages.

Here is are the two side by side, you'll notice that one has the attachments, while the other does not, I have highlighted the 2 differences between the pagefront and sub page jquery code. The odd part is the both php templates have been preprocessed with the correct #attached lines but one simply doesnt work (page front):

page--front.tpl.php:
jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"oasis_adaptivetheme","theme_token":"s2eetqVIaFXqXYRATimMNL0GYPcCpTDCjnO54lQuSOA","js":{"misc\/jquery.js":1,"misc\/jquery.once.js":1,"misc\/drupal.js":1,"misc\/ui\/jquery.ui.core.min.js":1,"misc\/jquery.ba-bbq.js":1,"modules\/overlay\/overlay-parent.js":1,"modules\/contextual\/contextual.js":1,"misc\/jquery.cookie.js":1,"sites\/all\/modules\/admin_menu\/admin_menu.js":1,"sites\/all\/modules\/devel\/devel_krumo_path.js":1,"modules\/toolbar\/toolbar.js":1},"css":{"modules\/system\/system.base.css":1,"modules\/system\/system.menus.css":1,"modules\/system\/system.messages.css":1,"modules\/system\/system.theme.css":1,"misc\/ui\/jquery.ui.core.css":1,"misc\/ui\/jquery.ui.theme.css":1,"modules\/overlay\/overlay-parent.css":1,"modules\/contextual\/contextual.css":1,"modules\/comment\/comment.css":1,"modules\/field\/theme\/field.css":1,"modules\/node\/node.css":1,"modules\/search\/search.css":1,"modules\/user\/user.css":1,"sites\/all\/modules\/views\/css\/views.css":1,"sites\/all\/modules\/admin_menu\/admin_menu.css":1,"sites\/all\/modules\/admin_menu\/admin_menu.uid1.css":1,"sites\/all\/modules\/ctools\/css\/ctools.css":1,"sites\/all\/modules\/panels\/css\/panels.css":1,"modules\/toolbar\/toolbar.css":1,"sites\/all\/themes\/adaptivetheme\/at_core\/css\/at.layout.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/global.base.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/global.styles.css":1,"public:\/\/adaptivetheme\/oasis_adaptivetheme_files\/oasis_adaptivetheme.responsive.layout.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.custom.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.smalltouch.portrait.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.smalltouch.landscape.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.tablet.portrait.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.tablet.landscape.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.desktop.css":1,"public:\/\/adaptivetheme\/oasis_adaptivetheme_files\/oasis_adaptivetheme.lt-ie9.layout.css":1}},"overlay":{"paths":{"admin":"import\nimport\/*\nnode\/*\/import\nnode\/*\/delete-items\nnode\/*\/log\nnode\/*\/edit\nnode\/*\/delete\nnode\/*\/revisions\nnode\/*\/revisions\/*\/revert\nnode\/*\/revisions\/*\/delete\nnode\/add\nnode\/add\/*\noverlay\/dismiss-message\nadmin\nadmin\/*\nbatch\ntaxonomy\/term\/*\/edit\nuser\/*\/cancel\nuser\/*\/edit\nuser\/*\/edit\/*\ndevel\/*\nnode\/*\/devel\nnode\/*\/devel\/*\ncomment\/*\/devel\ncomment\/*\/devel\/*\nuser\/*\/devel\nuser\/*\/devel\/*\ntaxonomy\/term\/*\/devel\ntaxonomy\/term\/*\/devel\/*","non_admin":"admin\/structure\/block\/demo\/*\nadmin\/reports\/status\/php"},"pathPrefixes":[],"ajaxCallback":"overlay-ajax"},"urlIsAjaxTrusted":{"\/search\/node":true,"\/content\/home":true},"adaptivetheme":{"oasis_adaptivetheme":{"layout_settings":{"bigscreen":"three-col-grail","tablet_landscape":"three-col-grail","tablet_portrait":"one-col-vert","smalltouch_landscape":"one-col-vert","smalltouch_portrait":"one-col-stack"},"media_query_settings":{"bigscreen":"only screen and (min-width:1025px)","tablet_landscape":"only screen and (min-width:769px) and (max-width:1024px)","tablet_portrait":"only screen and (min-width:581px) and (max-width:768px)","smalltouch_landscape":"only screen and (min-width:321px) and (max-width:580px)","smalltouch_portrait":"only screen and (max-width:320px)"}}},"tableHeaderOffset":"Drupal.admin.height","admin_menu":{"destination":"destination=node\/244","hash":"8af1c8ee1f6ff24dfc126528ccc33e62","basePath":"\/admin_menu","margin_top":1,"position_fixed":1}});

page.tpl.php:
jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"oasis_adaptivetheme","theme_token":"s2eetqVIaFXqXYRATimMNL0GYPcCpTDCjnO54lQuSOA","js":{"misc\/jquery.js":1,"misc\/jquery.once.js":1,"misc\/drupal.js":1,"misc\/ui\/jquery.ui.core.min.js":1,"misc\/jquery.ba-bbq.js":1,"modules\/overlay\/overlay-parent.js":1,"modules\/contextual\/contextual.js":1,"misc\/jquery.cookie.js":1,"sites\/all\/modules\/admin_menu\/admin_menu.js":1,"sites\/all\/modules\/devel\/devel_krumo_path.js":1,"sites\/all\/modules\/responsive_dropdown_menus\/theme\/responsive-dropdown-menus.js":1,"modules\/toolbar\/toolbar.js":1},"css":{"modules\/system\/system.base.css":1,"modules\/system\/system.menus.css":1,"modules\/system\/system.messages.css":1,"modules\/system\/system.theme.css":1,"misc\/ui\/jquery.ui.core.css":1,"misc\/ui\/jquery.ui.theme.css":1,"modules\/overlay\/overlay-parent.css":1,"modules\/contextual\/contextual.css":1,"modules\/comment\/comment.css":1,"modules\/field\/theme\/field.css":1,"modules\/node\/node.css":1,"modules\/search\/search.css":1,"modules\/user\/user.css":1,"sites\/all\/modules\/views\/css\/views.css":1,"sites\/all\/modules\/admin_menu\/admin_menu.css":1,"sites\/all\/modules\/admin_menu\/admin_menu.uid1.css":1,"sites\/all\/modules\/ctools\/css\/ctools.css":1,"sites\/all\/modules\/panels\/css\/panels.css":1,"sites\/all\/modules\/responsive_dropdown_menus\/theme\/responsive-dropdown-menus.css":1,"modules\/toolbar\/toolbar.css":1,"sites\/all\/themes\/adaptivetheme\/at_core\/css\/at.layout.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/global.base.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/global.styles.css":1,"public:\/\/adaptivetheme\/oasis_adaptivetheme_files\/oasis_adaptivetheme.responsive.layout.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.custom.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.smalltouch.portrait.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.smalltouch.landscape.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.tablet.portrait.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.tablet.landscape.css":1,"sites\/all\/themes\/oasis-adaptivetheme\/css\/responsive.desktop.css":1,"public:\/\/adaptivetheme\/oasis_adaptivetheme_files\/oasis_adaptivetheme.lt-ie9.layout.css":1}},"overlay":{"paths":{"admin":"import\nimport\/*\nnode\/*\/import\nnode\/*\/delete-items\nnode\/*\/log\nnode\/*\/edit\nnode\/*\/delete\nnode\/*\/revisions\nnode\/*\/revisions\/*\/revert\nnode\/*\/revisions\/*\/delete\nnode\/add\nnode\/add\/*\noverlay\/dismiss-message\nadmin\nadmin\/*\nbatch\ntaxonomy\/term\/*\/edit\nuser\/*\/cancel\nuser\/*\/edit\nuser\/*\/edit\/*\ndevel\/*\nnode\/*\/devel\nnode\/*\/devel\/*\ncomment\/*\/devel\ncomment\/*\/devel\/*\nuser\/*\/devel\nuser\/*\/devel\/*\ntaxonomy\/term\/*\/devel\ntaxonomy\/term\/*\/devel\/*","non_admin":"admin\/structure\/block\/demo\/*\nadmin\/reports\/status\/php"},"pathPrefixes":[],"ajaxCallback":"overlay-ajax"},"urlIsAjaxTrusted":{"\/search\/node":true,"\/content\/recipe":true},"responsive_dropdown_menus":{"devel":"Development","main-menu":"Main menu","management":"Management","navigation":"Navigation","menu-top-nav-left":"Top Nav Left","menu-top-nav-right":"Top Nav Right","user-menu":"User menu"},"adaptivetheme":{"oasis_adaptivetheme":{"layout_settings":{"bigscreen":"three-col-grail","tablet_landscape":"three-col-grail","tablet_portrait":"one-col-vert","smalltouch_landscape":"one-col-vert","smalltouch_portrait":"one-col-stack"},"media_query_settings":{"bigscreen":"only screen and (min-width:1025px)","tablet_landscape":"only screen and (min-width:769px) and (max-width:1024px)","tablet_portrait":"only screen and (min-width:581px) and (max-width:768px)","smalltouch_landscape":"only screen and (min-width:321px) and (max-width:580px)","smalltouch_portrait":"only screen and (max-width:320px)"}}},"tableHeaderOffset":"Drupal.admin.height","admin_menu":{"destination":"destination=node\/239","hash":"8af1c8ee1f6ff24dfc126528ccc33e62","basePath":"\/admin_menu","margin_top":1,"position_fixed":1}});

I'm going to hang it up for now to see what you are able to come up with. This could be a Drupal preprocess issue. I do not do a lot of theming most of the time so it's not something I am familiar with off hand.

mglaman’s picture

That's crazy! I can't wait for D8 when #attached is the right thing to do ;) I'll hang up the "fancy" hat and go bac to the old ways before this broke.

crystaldawn’s picture

Personally I think that #attached was the correct path, but I dont know why preprocess isnt actually doing what it's suppose to do which is to preprocess lol. I did try add_css and add_js but that didnt work either. I tried running v 1.0 as well, but then it didnt even work on sub pages. So idk if there is something extra that needs to be added to the template files for 1.0 or not. I assume so.

mglaman’s picture

Status: Active » Needs review
StatusFileSize
new1.52 KB

Can the attached patch be given a test run? If anyone thumbs up I'll commit.

crystaldawn’s picture

I just tested this and it does fix things. But why it works............ clueless lol. They should have both worked. Gremlins I tell ya, they are everywhere.

crystaldawn’s picture

Status: Needs review » Reviewed & tested by the community

  • mglaman committed 8f40e7d on 7.x-1.x
    Issue #2472977 by mglaman: JS not loaded on front page
    
mglaman’s picture

Status: Reviewed & tested by the community » Fixed

Yeah I don't get it either. Committed, though!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Yuri’s picture

The issue is still present, when using jquery update 1.8 and up.