Posted in JavaScript, Prototype.js on January 8th, 2008 2 Comments »
The DOM change notification I presented yesterday is one piece in the puzzle to rejuvenate my languishing JavaScript form validator. I’ve not yet made up my mind on a lot of issues, but there’s one thing that’s certain: the next version will have to be able to work with changing forms, that is, forms that [...]
Posted in JavaScript, Prototype.js on January 7th, 2008 1 Comment »
So we’ve put in the effort to make our JavaScript code nicely unobtrusive and all is well — until it isn’t. A pesky Ajax request has messed up the DOM and suddenly there are elements in there where our unobtrusive behavioral goodness has not been attached. Never give up, never surrender. You won’t even have [...]
Posted in JavaScript on December 30th, 2007 No Comments »
I’ve released a new version, 0.2.2, of the JavaScript FSM builder. There are some enhancements, such as accessors for successorStates and expectedEvents that I found useful for implementing a first (almost) practical example involving drag & drop.
Speaking of which, this whole thing didn’t come into being because of a pressing need. Currently, it’s more of [...]
Posted in JavaScript on December 22nd, 2007 3 Comments »
I like finite state machines and I wanted to try metaprogramming in JavaScript ever since I’d seen Adam McCrea presentation on the topic.
The result is an FSM builder in JavaScript. Machine descriptions look like my test machine here:
var Machine = FSM.build(function(fsm) { with (fsm) {
onUnexpectedEvent(function() { … });
state(’start’, ‘initial’)
[...]
Posted in CSS, JavaScript on February 22nd, 2007 No Comments »
Make your layout look good a different screen and font sizes.
What it looks like
Example 1,
Example 2.
Here’s what the form example (example 1) is supposed to look like.
At 1024 x 768 pixels, the navigation links and Save button are positioned fixed in a column to the left.
At 800 x 600 pixels, the navigation links are only [...]
Posted in CSS, JavaScript, Rails on February 22nd, 2007 No Comments »
On my continuing quest to become more Web-2.0-ish, I’ve tried my luck tilting at… well, tag clouds. To get an idea what I’m talking about, please have a look.
These are the rudimentary basics to create a tag cloud like that.
In the controller
def tags
@popular_tags = Tag.find_most_popular(:limit => 30)
end
In the view
<ul id=”tags” class=”tagcloud”>
<% @popular_tags.sort_by(&:name).each do [...]
Posted in JavaScript, Rails on January 31st, 2007 9 Comments »
See the end of this post for an important update.
Standard Rails auto-completion is geared toward completing a single value entered in a text field. For most cases this is exactly what’s needed, but there is one prominent case that is different: auto-completion of tags. If something can have a tag at all, it’s part and [...]
Posted in JavaScript, Rails, Ruby on December 15th, 2006 21 Comments »
Ruby on Rails already does a good job of specifying almost declaratively what conditions objects must meet to be considered valid–that is, how they are validated.
Thus, in order to make sure that a Person’s last_name attribute does not exceed 100 characters, you would write something like this
class Person < ActiveRecord::Base
validates_length_of :last_name, :maximum => [...]