Archive for September, 2009

jQuery tablesorter plugin and dates

Posted in jquery on September 21st, 2009 by paul – Be the first to comment

I recently discovered the exellent tablesorter jquery plugin for sorting tables of data. It works very well and saved a lot of time having to write server side sorting code.

I did hit a small snag with dates of the format “12 Aug 2008″. The default sorter seemed to be sorting on the day part of the date and ignoring everything else.

In the end I had to set the sorter for these columns as the isoDate sorter which works perfectly, once I set the dateFormat to “uk”.

eg

<script type="text/javascript" charset="utf-8">
 $(document).ready(function()
 {
   $("#pupils_table").tablesorter({
                                   headers: {
                                             4: {
                                                 sorter:'isoDate'
                                                 }
                                   },
                                   dateFormat: "uk"
                                   });
 }
 );
</script>

error undefined method `use_transactional_fixtures=’ for Test::Unit::TestCase:Class

Posted in rails on September 16th, 2009 by paul – Be the first to comment

When running some tests today I hit the error message: undefined method `use_transactional_fixtures=’ for Test::Unit::TestCase:Class

Searching for this came up with numerous results.

The way to fix this is to change the class in test/test_helper.rb from Test::Unit::TestCase to ActiveSupport::TestCase

Tests should run properly now.

This is while using rails 2.3.2 on OS X.

IE8 compatibility mode and cellpadding, cellspacing

Posted in Uncategorized on September 11th, 2009 by paul – Be the first to comment

I recently had a problem whereby a table with a dynamic number of rows had a space above it that I couldn’t explain initially.

The table was in a modal style dialogue with no markup above it before the start of the div. However, the gap betwen the top of the table and the top of the div was variable, depending on the number of rows in the table. The greater the number of rows, the bigger the gap; so clearly the table rows where the problem. I had set margin and padding to zero but that didn’t do it.

Eventually I tried setting the cellpadding and cellspacing to zero, and that fixed the problem.

This may be very obvious to markup experts but I hadn’t seen this before (or if I had I’d forgotten, hence this reminder).

Only a problem in IE8 in compatibility mode.

stop rails writting fieldwitherrors on error

Posted in Uncategorized on September 1st, 2009 by paul – Be the first to comment

It is usually quite handy to have rails wrap one’s form fields in a div to indicate which ones have an error but sometimes it can be a real pain.

Alex Vollmer shows you how to stop rails adding these extra divs to your form fields.