When deleting a wish, don't just hide the fields.
Make a separate AJAX call which deletes the wish (in the db), and
then removes the deleted wish from your document with the appropriate
prototype call.
So, once a wish has been removed, it's gone... and you don't have to
worry about it when updating the current wish list.
-- Patrick
On Mar 7, 2007, at 3:57 PM, Nathan Colgate Clark wrote:
Hey Everybody,
Part of a project I'm working on has a wishlist. I've got a List
model that has_many Wishes. (Think Ta-Da Lists by 37Signals). When
editing a list, all of the wishes are edited too. See the pastie:
http://pastie.caboo.se/45468
I'm using the "update" method to update all those wishes at once:
Wish.update(params['wish'].keys, params['wish'].values)
My problem is deleting a wish from the list. I've implemented the
little javascript function that hides the fields and sets their
values to "", but the controller doesn't know to delete it... it
just assumes it is missing. I need something in the controller that
checks to see if a wish has empty values, and if so, delete it. Is
there an existing method to do this? I'm thinking along the lines
of the little radio button trick that still sets the value to "0"
or "false" when the radio button isn't selected.
Thanks,
-Nathan
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby