[Sdruby] Iteration Code for IE Hack
Jordan A. Fowler
catch at quicktunes.net
Tue Jan 30 01:51:03 GMT 2007
On Jan 29, 2007, at 5:49 PM, Jordan A. Fowler wrote:
> Kevin,
>
> This should do it:
>
> <ul class="css">
> <% object.features.each_with_index do |f,i| -%>
> <%= %Q`</ul><ul class="css">` if (i != 0 and (i % 4 == 0)) %.
Oops, that's supposed to be a %> not %. above.
> <li class="css-li"><%= f.name %></li>
> <% end -%>
> </ul>
>
> 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:Kevin at BurkDesignGroup.com
>> 6161 El Cajon Blvd #306
>> San Diego, CA 92115
>> PHONE (619) 583-2311
>> FAX (619) 583-5801
>> ***************************************
>> _______________________________________________
>> Sdruby mailing list
>> Sdruby at lists.sdruby.com
>> http://lists.sdruby.com/mailman/listinfo/sdruby
>
> _______________________________________________
> Sdruby mailing list
> Sdruby at lists.sdruby.com
> http://lists.sdruby.com/mailman/listinfo/sdruby
More information about the Sdruby
mailing list