Here are Rob's Blog entries for April 2009.
As it was Easter yesterday, and I don't really like Hot Cross Buns, I decided to make variant of them, simple Sticky Buns. It's more or less the Hot Cross Bun recipe, but without the fruit and peel.
You will need
- 400g plain flour
- 50g of strong white flour (though you can just use all plain if you want)
- 50g caster sugar
- 50g melted butter
- 1 pack of dried yeast (the sort that doesn't need activating in water first)
- 1 tsp cinnamon powder
- half tsp ground ginger
- half tsp salt
- 150ml warm water
- 50ml warm milk
- 1 beaten egg
- Also, 1tbsp of caster sugar for glaze
- Sift together flours, cinnamon, ginger and salt.
- Mix in sugar and dried yeast
- Pour in water, milk, egg and butter and mix well
- Knead the dough on clean work surface for between 5 to 10 minutes until elastic
- Put in an oiled bowl, cover, and leave in a warm place to rise for about an hour
- Knock back the dough and seperate into 12 small balls. Place these on greased baking sheets
- Cover and let them rise again in a warm place for 30 minutes.
- Preheat over to gas mark 7, 220C, 425F
- Bake for 15 minutes
- When they come out, glaze with a mix or 1 part sugar to 1 part water melted in pan, then brushed over the surface.
- Enjoy!
These will only last about a day before going stale, but you probably won't run into that problem as they are to delicious to leave that long.
Entered: 2009-04-13 11:54:17
- Even Faster Websites Souders has a new-found obsession with simplifying CSS (cascading style sheet) selectors. He urges developers to avoid universal, descendant, and tag-child selectors, while sidestepping qualifiers for ID and class selectors.
Bookmarks from del.icio.us
Entered: 2009-04-04 00:15:02
One of the most powerful features of jQuery is it's plugin architecture. This allows developers to easily extend jQuery's functionality.
I've decided to extend my table striping example code and turn it into a jQuery plugin. If I have a table with an id of test, I want to be able to call a stripe function on it's selector, e.g. $('#test').stripe();
So how do we build this? Well firstly, as it's a plugin we shouldn't really be playing with the $ jQuery object incase our user has disabled it. There is a trick to get around this though...
(function($){
// code here can safely use $
})(jQuery);
What's happening here? Well we're using a closure to create an anonymous function into which we pass in the jQuery object. The parameter name we use in this function is
$ so we can use this inside safely, even if the user has disabled this variable outside our plugin.
Now we have our
$ variable we can get on with building the plugin.
$.fn.stripe = function(options) {
// define our function action here.
}
Here we've added a function to jQuery called stripe and told it to reference a fuction we've defined. Now we need to add the magic to this function to actually do the striping.
return this.each(function() {
$('/tbody:first>tr:even',this).addClass('even');
$('/tbody:first>tr:odd',this).addClass('odd');
});
As a jQuery selector can run over multiple items, we need to make sure we iterate over each of these. We use jQuery's built in each function to do this. this refers to the current selector in this case.
Inside, we need to select the first tbody element of the selection, then for each child tr depending if it's odd or even we set the class of that tr to be either even or odd. This should ensure that nested tables won't be striped.
That's great, but what would be even more useful would be the ability to define different class names dynamically so we're not stuck with the two hardcoded ones.
This is easy to achieve by creating a set of defaults in a private object, passing overrides into our function, and using jQuery's excellent extend function to merge the two.
var defaults = {
odd : 'dark',
even : 'lite'
};
var options = $.extend(defaults, options);
Now we can either just call .stripe directory, or pass in override options like this, .stripe({odd: 'testdark', even: 'testeven')
Putting this all together, we get the following code for our stripe plugin.
(function($){
$.fn.stripe = function(options) {
var defaults = {
odd : 'dark',
even : 'lite'
};
var options = $.extend(defaults, options);
return this.each(function() {
$('/tbody:first>tr:even',this).addClass(options.even);
$('/tbody:first>tr:odd',this).addClass(options.odd);
});
}
})(jQuery);
A configurable jQuery plugin, in just 13 lines of JavaScript. Marvellous!
Entered: 2009-04-03 18:47:34