Chris,

I was unaware of "in_groups_of" method, that's awesome!

-Jordan

On Jan 29, 2007, at 5:50 PM, Chris Abad wrote:

I'll get this out of the way first... this seems a bit extreme for an IE workaround and you're probably better off reworking your CSS. However, to answer your question, you can do this:

<% object.features.in_groups_of(4).each do |feature| %>
        <ul class="css">
                <% if feature %>
                        <li class="css-li">Feature <%= feature.id.to_s %></li>  
    
                <% end %> 
        </ul>
<% end %>

Couple things to note.
1. in_groups_of will pad the group w/ nil's where necessary.
2. This will split the section into groups for all browsers. You can then handle your CSS using an IE filter and an IE-only stylesheet.

On Jan 29, 2007, at 5:39 PM, Kevin Burk wrote:

Working around Microsoft's utter lack of support for web standards, I'm faced with needing a code hack so that the CSS that works in every other browser will display correctly in IE on Windows.

The issue is with an iterated list: to make the code work in IE, I have to limit each list to only 4 items. The challenge is that I don't know how many items will be in a given list.

Normally, I would use this code:

        <% object.features.each do |f| -%>
        <ul class="css">
                <li class="css-li"><%= f.name %></li>
        </ul>
        <% end %>

However, I now need to make sure that the output breaks the list at 4 items and then starts a new list:

        <ul class="css">
                <li class="css-li">Feature 1</li>
                <li class="css-li">Feature 2</li>
                <li class="css-li">Feature 3</li>
                <li class="css-li">Feature 4</li>
        </ul>
        <ul class="css">
                <li class="css-li">Feature 5</li>
                <li class="css-li">Feature 6</li>
                <li class="css-li">Feature 7</li>
                <li class="css-li">Feature 8</li>
        </ul>
        <ul class="css">
                <li class="css-li">Feature 9</li>
                <li class="css-li">Feature 10</li>
        </ul>

This is the only way that IE 6 for Windows will display the list correctly. I'd rather not go back the CSS drawing board and attempt to find a list style that IE will not choke on-but I have absolutely no idea of how I would go about coding this in ruby. An object can have any number of features, from 2 or 3 up to 20 to 25. Since the list style creates button blocks, I would like to avoid any empty blocks.

My first thought is that I'd have to pull all of the features into an array, count the number of features, divide by 4 to get the number of iteration blocks needed, and then generate all of the block code from that (although I can just about figure out how to create the array and count the items).

Is there a reasonably easy way to do this or should I give up and just try to find a CSS hack instead? I'd love to simply refer IE users to Firefox, but I don't think that would fly with my client.

Thanks in advance.

Kevin Burk


--
***************************************
BURK DESIGN GROUP
http://www.BurkDesignGroup.com
mailto:[EMAIL PROTECTED]
6161 El Cajon Blvd #306
San Diego, CA 92115
PHONE (619) 583-2311
FAX (619) 583-5801
***************************************
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to