And, it worked great. I used a variation on Option 1.

On Monday, November 5, 2012 11:02:48 AM UTC-8, [email protected] wrote:
>
> Wow, that is so thorough and clear and helpful.
>
> Thank you very much.
>
> On Monday, November 5, 2012 6:00:37 AM UTC-8, Bryan Larsen wrote:
>>
>> Here's a simplification of your code. 
>>
>> <do with="something_else_completely"> 
>>    <% @cu = CompanyUser.find(foo) %> 
>>    <div part="pledgeform" id="pledgeform-#{typed_id}"> 
>>       <form with="&@cu" update="pledgeform-#{typed_id}"> 
>>           ,,,, 
>>
>> 1:  the typed_id for pledgeform is going to return the typed_id for 
>> something_else 
>>
>> 2:  the typed_id for the form is not clear.   Does it get evaluated 
>> before or after the with= statement?   You may know, but it's best to 
>> assume that anybody else working with your code doesn't.  I really 
>> like do statements for changing contexts to make this clear. 
>>
>> 3:  When redoing the part, Hobo will set the context to 
>> something_else, then try to switch it to @cu when it hits the form. 
>> However, @cu won't be set, because it's set in a piece of code outside 
>> the part.  Only view code inside the part is run when the part is 
>> redisplayed. 
>>
>> Option #1: 
>>
>> <% @cu = CompanyUser.find(foo) %> 
>> <do with="&@cu"> 
>>    <div part="pledgeform" id="pledgeform-#{typed_id}"> 
>>       <form update="pledgeform-#{typed_id}"> 
>>           ,,,, 
>>
>> In this piece of code, the <% @cu = CompanyUser.find(foo) %> code only 
>> runs once.  Hobo remembers the id of the CompanyUser, and reloads it 
>> from the database when resurrecting the part, so you're guaranteed to 
>> get the same CompanyUser when redisplaying the part. 
>>
>> Option #2: 
>>
>> <% @cu = CompanyUser.find(foo) %> 
>> <do with="&@cu"> 
>>    <div part="pledgeform"> 
>>       <form ajax> 
>>           ,,,, 
>>
>> This is the same as option #1, except it takes advantage of some new 
>> features in Hobo 2.0.   See 
>> http://cookbook-1.4.hobocentral.net/manual/changes20#multiple_parts 
>> for more details. 
>>
>> If it's possible that you want a different @cu when redisplaying the 
>> part, use a form similar to: 
>>
>> <do with="&nil"> 
>>    <div part="pledgeform"> 
>>       <% @cu = CompanyUser.find(foo) %> 
>>       <form with="&@cu" ajax> 
>>           ,,,, 
>>
>> `do with="&nil"` outside of a part definition is a good pattern to use 
>> so that Hobo doesn't go to the work of resurrecting a context that 
>> you're immediately going to throw away. 
>>
>> If you're using this form, you have to take care to ensure that `foo` 
>> has validity, either by defining it as a helper method, as a variable 
>> inside your controller or by using part locals: 
>> http://cookbook-1.4.hobocentral.net/manual/ajax#local_variables 
>>
>> cheers, 
>> Bryan 
>>
>> On Sun, Nov 4, 2012 at 10:45 PM, [email protected] 
>> <[email protected]> wrote: 
>> > OK, I implemented this today. It seems to work except for the Ajax 
>> updating. 
>> > The problem seems to be that the typed_id is not being substituted into 
>> the 
>> > id field. 
>> > 
>> > The code for the H2 version is here: 
>> > 
>> >      http://pastie.org/5187078 
>> > 
>> > and, as an example, the generated HTML is: 
>> > 
>> >      http://pastie.org/5187103 
>> >     (that HTML gets a little chewed up in Pastie, but I think it is 
>> > parseable) 
>> > 
>> > Any ideas about what might prevent typed_id from being generated? 
>> > 
>> > Thanks so much! 
>> > 
>> > 
>> > On Friday, October 19, 2012 12:06:36 PM UTC-7, Bryan Larsen wrote: 
>> >> 
>> >> You can replace ajax with update="companyuserform-#{typed_id}" and it 
>> >> should work on 1.3 too.  Also on 1.3 it will be more difficult to get 
>> >> it to display inline rather than using block styling. 
>> >> 
>> >> Bryan 
>> >> 
>> >> On Fri, Oct 19, 2012 at 2:56 PM, [email protected] 
>> >> <[email protected]> wrote: 
>> >> > Cool. 
>> >> > 
>> >> > This would not work in 1.3, bcs. fo the Ajax keyword, right? 
>> >> > 
>> >> > 
>> >> > On Friday, October 19, 2012 11:52:38 AM UTC-7, Bryan Larsen wrote: 
>> >> >> 
>> >> >> Off the top of my head: 
>> >> >> 
>> >> >> <form ajax> 
>> >> >>   <hidden-field:id/> 
>> >> >>   <hidden-field:pledged-date value="&Date.today"/> 
>> >> >>   <submit label="Yes"/> 
>> >> >> </form> 
>> >> >> 
>> >> >> Bryan 
>> >> >> 
>> >> >> On Fri, Oct 19, 2012 at 2:48 PM, [email protected] 
>> >> >> <[email protected]> wrote: 
>> >> >> > I have a 1.3 app that uses an <update-button> tag. I am planning 
>> to 
>> >> >> > migrate 
>> >> >> > the app to 2.0, so I see in the release notes that I need to 
>> replace 
>> >> >> > the 
>> >> >> > <update-button>. 
>> >> >> > 
>> >> >> > The current tag using it is here: 
>> >> >> > 
>> >> >> >      http://pastie.org/5085380 
>> >> >> > 
>> >> >> > Can I get some guidance on the best way to replace the 
>> >> >> > <update-button> 
>> >> >> > on 
>> >> >> > line 11 with a 2.0-compatible construct? 
>> >> >> > 
>> >> >> > Thanks! 
>> >> >> > 
>> >> >> > -- 
>> >> >> > You received this message because you are subscribed to the 
>> Google 
>> >> >> > Groups 
>> >> >> > "Hobo Users" group. 
>> >> >> > To view this discussion on the web visit 
>> >> >> > https://groups.google.com/d/msg/hobousers/-/DGBla5zVWMQJ. 
>> >> >> > To post to this group, send email to [email protected]. 
>> >> >> > To unsubscribe from this group, send email to 
>> >> >> > [email protected]. 
>> >> >> > For more options, visit this group at 
>> >> >> > http://groups.google.com/group/hobousers?hl=en. 
>> >> > 
>> >> > -- 
>> >> > You received this message because you are subscribed to the Google 
>> >> > Groups 
>> >> > "Hobo Users" group. 
>> >> > To view this discussion on the web visit 
>> >> > https://groups.google.com/d/msg/hobousers/-/ZK_pRok6vNwJ. 
>> >> > 
>> >> > To post to this group, send email to [email protected]. 
>> >> > To unsubscribe from this group, send email to 
>> >> > [email protected]. 
>> >> > For more options, visit this group at 
>> >> > http://groups.google.com/group/hobousers?hl=en. 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups 
>> > "Hobo Users" group. 
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msg/hobousers/-/F8D1APAsmIUJ. 
>> > 
>> > To post to this group, send email to [email protected]. 
>> > To unsubscribe from this group, send email to 
>> > [email protected]. 
>> > For more options, visit this group at 
>> > http://groups.google.com/group/hobousers?hl=en. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/hobousers/-/CAUsmTGQxc0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to