Is it not possible to generate 'part' attribute values?

13 views
Skip to first unread message

Andy Orahood

unread,
Oct 23, 2008, 10:54:13 AM10/23/08
to Hobo Users
I've got a table. In each row, I'd like to have a cell containing a
text field that dynamically updates a collection also in that cell. So
I need a uniquely identified part for each of these cells. I thought I
could use the model_id_class helper to give me a unique id to pass to
the part attribute like this (simplified to remove the irrelevant
fields):

<table:list-items fields="notes">
<notes-view:>
<collection part="&model_id_class"/>
<form with="&this.new" owner="list_item"
update="&model_id_class" >
<field-list />
<submit: label="Add note"/>
</form>
</notes-view:>
</table:list-items>

But I get an "invalid part" error whenever I put anything other than
text in the value for part. Even underscores cause the error.

Thanks,
Andy

Andy Orahood

unread,
Oct 23, 2008, 5:06:45 PM10/23/08
to Hobo Users
Ok I figured it out: you use the id attribute to generate a unique id
for a particular part:

- <collection part="&model_id_class"/>
- <form with="&this.new" owner="list_item"
update="&model_id_class" >

+ <collection part="notes" id="&this_parent"/>
+ <form with="&this.new" owner="list_item"
update="&this_parent.to_s" >

This creates the following output:

<div class='part-wrapper' id='List Item 1'>

and so on for each List Item in the table, with corresponding forms
with the attribute onsubmit="Hobo.ajaxRequest(this, ['List Item 1'],
{resetForm:true}); return false;" Nice!

A further question: How would I get a nice dasherized id ("list-
item-1") instead of the to_s version?

Thanks,
Andy

Tom Locke

unread,
Oct 24, 2008, 4:09:49 AM10/24/08
to hobo...@googlegroups.com
> Ok I figured it out: you use the id attribute to generate a unique id
> for a particular part:

Correct : )

I added a recipe on this issue:

http://cookbook.hobocentral.net/recipes/8-use-parts-on-repeated-elements

Tom

blizz

unread,
Oct 24, 2008, 4:31:44 PM10/24/08
to Hobo Users
> http://cookbook.hobocentral.net/recipes/8-use-parts-on-repeated-elements

This link returns


We're sorry, but something went wrong.

We've been notified about this issue and we'll take a look at it
shortly.

Andrew Shindyapin

unread,
Oct 24, 2008, 4:32:49 PM10/24/08
to hobo...@googlegroups.com
That message looks mighty familiar... looks like the cookbook is on heroku.

James Garlick

unread,
Oct 24, 2008, 4:35:56 PM10/24/08
to hobo...@googlegroups.com
No, that's the default Rails 500 page.

paulj...@gmail.com

unread,
Nov 21, 2011, 4:17:53 PM11/21/11
to hobo...@googlegroups.com
Just used this recipe in a form that appears in a card and it worked great.

Thanks so much!

Reply all
Reply to author
Forward
0 new messages