Ruby on Rails Friday, November 10, 2017

ok this is what I tried in one of my menus

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" role="button" aria-haspopup="true" aria-expanded="false">Categories<span class="caret"></span></a>
<ul class="dropdown-menu">
<% all_categories.each do |category| %>
<li><%= link_to category.name, category_path(category) %></li>
<% end %>
<li role="separator" class="divider"></li>
<li><%= link_to "All Categories", categories_path %></li>
</ul>
</li> I added 'data-hover="dropdown" data-delay="1000"' to the href tag.

On Friday, November 10, 2017 at 4:08:54 PM UTC-5, Walter Lee Davis wrote:

> On Nov 10, 2017, at 3:53 PM, Joe Guerra <jgu...@jginfosys.com> wrote:
>
> I'm trying to follow this ...
>
> https://github.com/CWSpear/bootstrap-hover-dropdown
>
> and add hover to my drop down menus.  
>
> But, I'm not sure what to do with the javascript in this situation?  Do I add it to the application.js manifest or do I add the requirements in the application.html?

Reading the Usage section of the README, it appears that all you need to do is to add this file to your vendor/assets/javascripts folder, add a reference to this script into your application.js manifest, then add the data-hover="dropdown" attribute either in place of data-toggle="dropdown" or alongside it (so both events cause the dropdown to appear).

If you're adding this to your link with the normal Rails view helpers, then you already have

link_to(nil, 'Account', class: 'dropdown-toggle', data: { toggle: 'dropdown' })

Change that to read

link_to(nil, 'Account', class: 'dropdown-toggle', data: { toggle: 'dropdown', hover: 'dropdown' })

and you're done.

Walter

>
> Thanks,
> Joe
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6df61ead-8b0b-4ce7-9981-4aefef7d77b6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f19f5f74-84a5-4269-9337-f155f2e68c0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment