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
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Dan Webb  
View profile   Translate to Translated (View Original)
 More options 24 Jan 2008, 14:25
From: "Dan Webb" <d...@danwebb.net>
Date: Thu, 24 Jan 2008 14:25:50 +0000
Local: Thurs 24 Jan 2008 14:25
Subject: Re: Railscasts' complex forms - refactoring with LowPro

> 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

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