Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Railscasts' complex forms - refactoring with LowPro

View Parsed - Show only message text

Received: by 10.65.132.13 with SMTP id j13mr11099302qbn.2.1201184750999;
        Thu, 24 Jan 2008 06:25:50 -0800 (PST)
Return-Path: <d...@danwebb.net>
Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.224])
        by mx.google.com with ESMTP id y6si4911800nzg.1.2008.01.24.06.25.50;
        Thu, 24 Jan 2008 06:25:50 -0800 (PST)
Received-SPF: neutral (google.com: 64.233.184.224 is neither permitted nor denied by best guess record for domain of d...@danwebb.net) client-ip=64.233.184.224;
Authentication-Results: mx.google.com; spf=neutral (google.com: 64.233.184.224 is neither permitted nor denied by best guess record for domain of d...@danwebb.net) smtp.mail=...@danwebb.net
Received: by wr-out-0506.google.com with SMTP id 60so38885wri.8
        for <low-pro@googlegroups.com>; Thu, 24 Jan 2008 06:25:50 -0800 (PST)
Received: by 10.151.10.7 with SMTP id n7mr318096ybi.144.1201184750739;
        Thu, 24 Jan 2008 06:25:50 -0800 (PST)
Received: by 10.150.153.1 with HTTP; Thu, 24 Jan 2008 06:25:50 -0800 (PST)
Message-ID: <5b3e279f0801240625k22feb67ai6521ad730611e5e4@mail.gmail.com>
Date: Thu, 24 Jan 2008 14:25:50 +0000
From: "Dan Webb" <d...@danwebb.net>
To: low-pro@googlegroups.com
Subject: Re: Railscasts' complex forms - refactoring with LowPro
In-Reply-To: <3ac854a4-d8a5-413e-9adc-1a7aa5d6ef7b@i3g2000hsf.googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <ca475362-eae3-4480-9354-05e698268803@x69g2000hsx.googlegroups.com>
	 <3ac854a4-d8a5-413e-9adc-1a7aa5d6ef7b@i3g2000hsf.googlegroups.com>

> The only problem with this is that I've used a remote link, so it's
> had to go back to the server, rather than all be done client side as
> it was before... is there another way?
>

The add_task_link helper in that example returns some ugly
HTML/JavaScript.  That's a great example of something that looks
perfectly acceptable at the Ruby end but is in fact pretty damn nasty.

There's a few approaches you could take.  The first one would be to
clone one of the previous task chunks and appendChild to the form.  A
nice way to do this is write a behaviour that clones a copy as soon as
the page is loaded (while the form values are still blank) then makes
clones from that as needed.  The second is that you could basically do
what add_task_link does:

Event.addBehavior({
  '#add_task_link:click': function() {
    $('taskform').insert(<%= render(:partial => 'project/task', ...).to_json);
  }
});

Not that Im just calling render then to_json on the result to turn it
into a JS quoted string.  Third option would be to use DOM Builder.
I'd go with cloning nodes though, it seems cleaner.

-- 
Dan Webb
http://www.danwebb.net

aim: danwrong123
skype: danwrong

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google