sscirrus
sscirrus

Reputation: 56729

IE renders a Rails loop twice - all other browsers render once

Here is a simple loop written in .html.erb.

For each portfolio_item we create a box in a 3-column grid. Note that <div class="portfolioOptions"> is hidden but appears onmouseover, covering <span id="title">.

In IE 7, 8, and 9, for each @portfolio_item, I am getting a box that functions followed by a second empty box!. Even IE's HTML source only shows one box.

<div class="gridRow">
    <% @portfolio_items.each do |item| %>
    <%= link_to params.except(:controller,:action).merge(:controller=>"portfolio_items", :action=>"show", :id=>item.id) do %>
    <div class="boxHalf portfolioBox" id="<%= item.id %>">
        <div class="portfolioItem">
            <% if item.url.present? && item.url_type == "vid" %>
              <%= item.vid_thumb.html_safe %>
            <% else %>
              <%= image_tag item.item.url(:medium) %>
            <% end %>
            <div class="text" title="<%= item.title %>">
                <span id="title_<%= item.id %>"><%= item.title %></span>
                <div class="portfolioOptions" id="option_<%= item.id %>">
                    <%= link_to 'Show', item, :class=>"blueButton" %>
                    <%= link_to 'Edit', edit_portfolio_item_path(item, :source=>"index"), :class=>"blueButton" %>
                    <%= link_to 'Delete', item, :confirm => 'Are you sure?', :method => :delete, :class=>"blueButton" %>
                </div>
            </div>
        </div>
    </div>
    <% end %>
    <% end %>
</div>

Relatively minor additional problem - the portfolioOptions mouseover doesn't display in IE, but I'll leave that as a subordinate to the double-box problem.

Upvotes: 0

Views: 208

Answers (1)

nathanvda
nathanvda

Reputation: 50057

Try validating the HTML that comes out of this. You wrap the div inside a link_to, and it contains links itself. Is that valid html? As far as i know a <a> element cannot contain a block-level element, or another <a> again.

Not sure how that should behave either.

Upvotes: 1

Related Questions