Blog Archives

Animating Table Rows with jQuery

Posted in AuroraCMS, Code, Product Reviews, Tips and Tricks

Animating table rows in the browser is problematic. You see, they aren’t block elements and as such don’t have a height or width property. Instead they take their constraints from the content inside them, and the elements that contain them. For rows this typically means they’re constrained by the containing table, and filled by the contained columns.

Today I wanted to slide a row up, and then when it had finished sliding I wanted to remove it from the DOM. Essentially giving it a nice effect when something is deleted.

Given that the height of a row is controlled by it’s content, I figured the easiest way to do this would be to wrap all of the content inside each column with a block element, in this case a div, and then resize those.

jQuery makes this extremely easy :

var el = $(options.element_prefix + id);
el.children("td").each(function() {
    $(this).wrapInner("< div />").children("div").slideUp(function() {el.remove();})
});

NOTE : The div tag in the wrapInner() is malformed because it won’t display properly otherwise. Please remove the space between the opening bracket and ‘div’.

It’s all pretty easy to understand. Essentially my root element is a row, and so for each td in that row wrap it’s content in a div. Then for the child divs in each td, run the slideUp() method. The callback in the slideUp() method says after the animation is done, remove the row. Given the speed of computers these days, no one will notice that the last few columns quite likely just vanish instead of complete their animation.

Better Ways For Laying Out HTML Forms

Posted in Code, Websites or Tools

The project I’m currently working on involves creating a lot of very large and somewhat complex forms. I hadn’t investigated better ways to create HTML forms for quite a while but this seemed like the perfect opportunity to do so.

After a quick search I found a great page with some tips on how to better layout forms using CSS, and some new tags such as Fieldset, Label and Legend. This allowed me to create the forms I needed in half the time, using half the markup. The end result were forms that look at least twice as good as the forms I’d created using my old ways and means.

It just reinforces to me how important it is to keep up in IT!

Twitter

Great web stats at @petrescue , the driving force behind the rebuild of their systems by @frontiergroup . http://t.co/MTvfoxnU

@frontiergroup about 3 weeks ago #

Search Posts

Featured Posts

Categories

Archives

View more archives