Things I Learned This Week
It's been a busy week, working on a fancy/complicated Web project. Here's a smattering of things I've learned:
IE7 breaks old assumptions about
You can't (easily) style
legend in Mozilla/Firefox
The main problem I was having with the new forms was trying to move the
legend around. Worked fine in IE, but was seriously wonky in Firefox. Turns out, this is a known bug in Mozilla/Firefox. I couldn't find a satisfying way to combat the defaults, so I gave ultimately up pixel-perfection here, but it's weird having something that IE handles better than Mozilla does.
You can run old IE and new IE on one machine
I downloaded IE7 pretty early in the "beta" process, then backed out and removed it. Last week, when it "officially" launched, I dove back in. But IE6 is still the gold standard, faster or not, IE6 will be here for some time to come (IE7 is currently XP- and Vista-only).
While BrowserCam is indispensible (especially the VNC-powered "remote access" feature), there's still no replacement for a locally available copy of the world's monopolist dominant browser. Thanks to archives available at Evolt, it is possible to run stand-alone copies of IE6 (or 5.5, or earlier) side-by-side with the new IE7.
Unfortunately, I've encountered one or two odd problems with the IE6 available there. It's an old archive, and it appears to deploy a patch/workaround for the Eolas patent issues. So, that's one: Flash or other "Active" content will work… oddly. It also appears to disable cookies, and have extremely limited support for PNGs (at least, my standard array of PNG "fixes" for pre-7 IE stopped working.)
Scriptaculous' Sortables are tricky
So, I've grown mighty attached to the one-two punch of Scriptaculous and Prototype, but the documentation is still frustratingly lacking (with at least one notable exception) . The Sortables demo , for example, doesn't really handle multiple groups, and the demo at Greg Neustaetter's site, while better, doesn't actually work.
I'll try to put a demo together myself, but here's what I've learned, anyway:
- Names matter: You need to set ids on your group and list-items that match. So,
group_1_item2and so forth. Note: You can override the pattern by setting the
formatisn't actually documented… anywhere (yet).
- Dynamic group adder: Greg (smartly) uses a function called
createLineItemSortablesto create the Sortables, rather than in-line
script. This allows him to call this
createLineItemSortableswhen he adds another group to the DOM. The alternative, is pulling in an updated page via Ajax. In my case, I found that Greg's method successfully animated the sortable elements, but messed up on
update. That is: It fired an XHR request, but consistently serialized the wrong element. My solution? Instead of
Sortable.serialize(this), pass the container
updatefunction and use that explicitly.
- When moving from one group to another, two
updaterequests will fire (once for each group)… except. When removing the last item from a group, that group's
updatewon't include any parameters; they'll just be blank_. If you're depending on the
group_idcoming in this way, it won't work; you'll get an empty
post. Instead, attach the
group_idto the URL in the
updaterequest, like @'/server_sidesort?group='+container.id@