mwlang / gentelella-rails

Injects the gentelella theme and javascript files into Rails assets pipeline
MIT License
155 stars 50 forks source link

Dropdowns don't seem to be working. #1

Open ghost opened 7 years ago

ghost commented 7 years ago

I followed the instructions to the letter, but the dropdown menus don't work. Is there something I am missing?

mwlang commented 7 years ago

I didn't heavily test. Which specific page and dropdown menu are you looking at? Are you able to see it working from the demo app I published? https://github.com/mwlang/gentelella-rails-demo

mwlang commented 7 years ago

@buffalods any luck?

jayjlawrence commented 7 years ago

I encountered the same issue. I just did a fresh install of both projects and got up and running nicely. The dropdowns don't work. It seem like they're not getting setup after document load.

Calling

makes them work.

I had no warnings. This is using Safari 10.0 and also Chrome Version 56.0.2924.87 (64-bit)

Other things are broken too (like modal windows). I forked the projects and am going to see if I can address this issue. I'd like to give the Gentelella admin UI for both an OSS as well as work project so I'm quite keen to make this work well.

mwlang commented 7 years ago

@jayjlawrence thanks for the detailed info. With that, I was able to quickly fix. I've pushed a new release 0.1.1 and the fix is on master branch as well.

mwlang commented 7 years ago

I think that the bootstrap init javascript isn't loading late enough in the chain. Reopening this one to look into also fixing modal windows, etc.

huanlv94 commented 7 years ago

I also encountered similar problems, how to solve it ?.

mwlang commented 7 years ago

I found the root cause to this problem. Turns out I made a mistake including "bootstrap-sprockets" AND "bootstrap" in the gem's main coffee script file that pulls in all the various dependencies. Removing the "bootstrap-sprockets" line resolved dropdowns, modals, and other bootstrap JS dependent functionality.

Both this gem and the demo project are updated.

kirillseva commented 6 years ago

@mwlang it's back

kirillseva commented 6 years ago

gem version 0.1.11, confirmed that 'gentellela-custom' is the last piece of javascript to be loaded. When I copypaste the whole script into dev console functionality is restored. Looks like something is fishy with regards to how sprockets are bundling all this.

Also tried replacing document.ready(... with document.on('turbolinks:load', ... - still no luck. If you ever get around to looking at this issue please advice on what would be the best course of action to debug this.

kirillseva commented 6 years ago

The problem turned out to be, as usual, caused by turbolinks and no longer existing JS globals.

https://github.com/mwlang/gentelella-rails/blob/8d74299fe0d7816bcbf0abd916cf60493560282d/lib/generators/gentelella/install/templates/gentelella-custom.js#L42-L50

The simplest solution is to just wrap the whole damned thing in $(document).on('turbolinks:load', function() {...});

hatjc-zz commented 6 years ago

similar issue need help really stuck on this non working menu

mwlang commented 6 years ago

@kirillseva and @hatens Sorry for my non-responsiveness on this. I've been under a heavy workload for a while. from the sounds of it, it does sound like a turbo-link issue. It may not be a document-load/ready issue, but a rather firing the correct event against turbo-links when menus are clicked. I cannot rightly recall exactly the turbo-link mechanism for this off the top of my head, but wanted to offer this quick suggestion as it may be some time before I can circle back to this and review in-depth.

Also, if one of you would put up a non-working example project that demonstrates the broken feature, I can review a bit quicker!

hatjc-zz commented 6 years ago

@mwlang this turbo link issue also affects the navigation? and what can be the measure to solve this temporarily before a solution is found?

huanlv-starx commented 6 years ago

var CURRENT_URL = window.location.href.split('#')[0].split('?')[0] Why not: var CURRENT_URL = window.location.origin + window.location.pathname ?