Ajax & Javascript woes

34 views
Skip to first unread message

tonym

unread,
Nov 13, 2012, 5:52:58 PM11/13/12
to hobo...@googlegroups.com
Hi All,
I've been getting on well with Hobo, and close to completing my first project...  but stuck with ajax and javascript issue.  Hope someone can help.

I can't figure out how, (or if it is possible) to redirect after an ajax create (and ideally update too).  I've tried what  I can find in the documentation, but nothing seems to work.

I'd like to avoid using ajax forms, but I've used hot-input due to the complexity of the form and changing prompts.
I've tried using javascript instead to modify the form live, which works well to some extent, but oddly I'm getting this error on some check boxes (but not all of them??)...

This works:

<field-list: fields="standard_ticket, q_concessions">
  <q-concessions-view>
    <input merge onclick="if ($(this).attr('checked')) { $('#q-concessions-desc').fadeIn(); } else { $('#q-concessions-desc').fadeOut(); }"/>
  </q-concessions-view:>
</field-list:>
<div id="q-concessions-desc"><field-list: fields="concessions_desc"/></div>

This fails with the error 'undefined method `attributes' for #<#<Class:0x3391a2c>:0x3396ae0>' :

<field-list: fields="q_18s">
  <q-18s-view:><input merge onclick="if ($(this).attr('checked')) { $('#time-18s-disp').fadeIn(); } else { $('#time-18s-disp').fadeOut(); }"/></q-18s-view:>
</field-list>
<div id="time-18s-disp">
  <field-list fields="time_18s" />
</div>


Both are check boxes, defined the same, I can't see how anything can be different:

q_concessions :boolean
q_18s :boolean

Cheers, Anthony.

Vivek Sampara

unread,
Nov 14, 2012, 2:14:44 AM11/14/12
to hobo...@googlegroups.com
Anthony , 

Try 

<q-18s-view:><input merge onclick="if (jQuery(this).attr('checked')) { jQuery('#time-18s-disp').fadeIn(); } else { jQuery('#time-18s-disp').fadeOut(); }"/></q-18s-view:>

Vivek


--
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/-/gW0vL8urc68J.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.

tonym

unread,
Nov 14, 2012, 5:13:48 AM11/14/12
to hobo...@googlegroups.com
Thanks for the quick response Vivek, 
but it isn't the jquery that's causing the problem.  A little testing and I found that this fails:  <input merge />
and the ones that work are outside the ajax <do part> so it looks like <do part> causes some sort of conflict with the input merge.  Good news for me is that I'm planning to replace the ajax parts with jquery.  Something to keep in mind though if you're using ajax.

Regards, Anthony.

Vivek Sampara

unread,
Nov 14, 2012, 5:54:40 AM11/14/12
to hobo...@googlegroups.com
Anthony , 

One of option is try giving them ids manually and then use jQuery("#yourid").change( function () { if (jQuery("#yourid").attr('checked')) { jQuery('#time-18s-disp').fadeIn(); } else { jQuery('#time-18s-disp').fadeOut(); }); 

Cheers
Vivek


To view this discussion on the web visit https://groups.google.com/d/msg/hobousers/-/9rm3tqRGId8J.

Bryan Larsen

unread,
Nov 14, 2012, 8:48:52 AM11/14/12
to hobo...@googlegroups.com
Parts need to be able to exist independently. Hobo does some "magic"
to ensure that the context gets resurrected correctly, but most other
dependencies need to be handled by your code.

In your case, you could serialize `attributes` by adding them to the
part-locals for your part. Then, you can use merge-attrs rather than
merge, and it should work. Rather than using merge-attrs inside a
part, I prefer to deal with each possible attr separately. So rather
than <input merge-attrs/> I would use <input value="&foo"> and ensure
that foo is either defined inside the controller, the part or in the
part-locals.

Bryan
> https://groups.google.com/d/msg/hobousers/-/9rm3tqRGId8J.
Reply all
Reply to author
Forward
0 new messages