简体   繁体   中英

nested tag rails issue

I don't understand this output. I have this

<%= link_to(:class=>"dropdown-toggle", "data-toggle"=> "dropdown") do %>
    <%= content_tag(:span, :class=>"hidden-xs-only") do %>
        <%= link_to("Sign Up", new_user_registration_path) %>
    <% end %>
<% end%>

but it outputs this

<a class="dropdown-toggle" data-toggle="dropdown">
    <span class="hidden-xs-only">
    </span>
</a>
<a href="/users/sign_up">Sign Up</a>

Sorry, nesting <a> tags is not valid HTML.

Use a <ul> or <div> for the outer element


You'd have to use javascript to toggle the child elements anyway, so yes, just add an onclick listener with a function that displays/hides the dropdown

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM