Archive for May, 2011

Dear Black Yukon

My wife and I had an interesting experience that I just need to share. We went to Lowe's to pick up some paint supplies. When we came back to our car, a lady across the parking lot flagged us down and told us that the vehicle beside us whacked our car really hard with her door. I looked it over and decided I could buff it out. My wife decided to leave them a little note just to let them know they were busted. It went something like this:

Dear Black Yukon:
A lady in the parking lot saw you hit our car with
your door. Please be more careful next time.
Sincerely,
Gray Xterra
{phone number}

She left it under their windshield wiper and we went on with our errands. While we were driving we had a little debate, will they own up to what they did and call us back? This question left me excited to get home. I knew they had found the note by now, so we should have a phone call waiting, right?

When we got home there was the missed call and the voicemail. He said something along the lines of, "I'm really sorry please give me a call back so that I can make this right." I was a little shocked. Obviously that was the right thing to do, but I really wasn't expecting it. I quickly ran out to the garage and buffed out the scratch to confirm that we were cool. I then called him back and let him know that everything was okay and thanked him for calling us. He apologized again and we hung up. My faith in humanity is restored.

I have to hand it to my wife, I never would have thought to leave a "you just got busted" note. Normally I see these things going one of three ways:

  1. Shrug it off and pretend like it never happened. The other person never knows they did anything wrong.
  2. Wait for person to come out and confront them.
  3. Kick in their door and then leave.

I would never do number three. For me to follow thorough with number two the damage would have to be significant. Number one is the typical route for me since I'm generally non-confrontational. My wife just introduced me to the 4th option, leave a shame-on-you note. :)

Knockout.js Money Observable

A few days ago I posted a solution to create a custom money binding for knockout.js. If you recall, I was a bit hesitant about the solution because I felt that it wasn't very semantic. Namely, DOM objects do not have a money property to bind to. I had a chat with Elijah Manor and he shared the same reservations. Comments on that post echoed the yucky feeling. Time for round 2.


See the full sample on jsFiddle

What I had missed was the writable dependentObservable introduced in knockout.js some time recently. With this new found power I can keep the appropriate text or value bindings and still have a clean view model. With the solution above, I don't have to jump through hoops to get a clean json representation of my view model. On top of that, my bindings are still simple enough to understand. There is less magic and I like it that way.

This feels a lot better than the first solution. I'm still not sold though. It feels like this type of concern should be pushed out of the view model. Possibly something like this? <input data-bind="value:Cash" data-convert="value:MoneyConverter" />

What do you think of the new bits? Is this a better or worse solution? Also, how can we improve this?

Knockout.js Custom Money Binding

EDIT: I think I've found a better solution. Click here to see the post on creating a money observable.

As I've been digging deeper into knockout.js, I had a need to simplify some things. I needed to have my view model hold float values but display it as a formatted money value. Time to write my own custom binding for knockout.

I'm a bit mixed about this. On one hand, it was dead simple to get the behavior I needed. On the other, the semantics don't match up. The built in bindings are things like text and value. That is, you are mating an object to the text or value property of a DOM element. DOM elements don't have a 'money' property, which makes this approach feel wrong.

There it is and I'm not confident that I'm using the tool appropriately. What do you think?