Issue with hobo and jquery.

17 views
Skip to first unread message

Peter Pavlovich

unread,
Feb 25, 2012, 1:10:01 AM2/25/12
to Hobo Users
Greetings,

I am trying to use the "datepicker" control from the hobo-jquery gem.
Here is what I have in my application.dryml:

<def tag="input" for="Date">
<datepicker />
</def>

And here is what the tag generated:

<input type="text" id="" data_rapid="{&quot;datepicker&quot;:
{&quot;options&quot;:{&quot;dateFormat&quot;:&quot;yy-mm-
dd&quot;},&quot;events&quot;:{}}}">

Does this look correct? The thing is that this renders as a regular
entry field. When this field receives focus, I expected it to pop up a
date picker widget. It doesn't. It does have a different visual
emphasis effect than other normal entry fields when it has focus (the
"glow" around the outside of the field has rounded corners, for
example), but it otherwise behaves as any other "normal" entry field.

Am I doing something wrong here?

Thanks again!

Peter

Bryan Larsen

unread,
Feb 25, 2012, 1:31:40 AM2/25/12
to hobo...@googlegroups.com
I notice that you're using the no-prototype alpha.

On Sat, Feb 25, 2012 at 1:10 AM, Peter Pavlovich <pavl...@gmail.com> wrote:
> Greetings,
>
> I am trying to use the "datepicker" control from the hobo-jquery gem.
> Here is what I have in my application.dryml:
>
> <def tag="input" for="Date">
>  <datepicker  />
> </def>
>
> And here is what the tag generated:
>
> <input type="text" id="" data_rapid="{&quot;datepicker&quot;:
> {&quot;options&quot;:{&quot;dateFormat&quot;:&quot;yy-mm-
> dd&quot;},&quot;events&quot;:{}}}">

There are two potential problems here.

1) it should be data-rapid rather than data_rapid.

2) the &quot should be \". Hopefully this is a cut and paste problem
rather than a real problem.

#1 looks like bug #994. Is it possible that you're using a version of
Hobo (jquery branch) from before Jan 11? If so, can you bundle
update hobo and try again?

thanks,
Bryan

Peter Pavlovich

unread,
Feb 26, 2012, 11:54:57 PM2/26/12
to Hobo Users
Turns out this was a bug which Bryan promptly corrected and pushed the
fix up to github. Works like a charm now.

Thanks Bryan!!!

On Feb 25, 1:31 am, Bryan Larsen <br...@larsen.st> wrote:
> I notice that you're using the no-prototype alpha.
>

Bryan Larsen

unread,
Feb 27, 2012, 12:50:19 AM2/27/12
to Peter Pavlovich, Hobo Users
Copied question (snipped heavily) and answers to the list, assuming
Peter doesn't mind. I hope I'm not wrong. :)

On Sun, Feb 26, 2012 at 11:12 PM, Peter Pavlovich <pavl...@gmail.com> wrote:
> Greetings,
>

> Sorry for all the questions. I hope you don't mind :)
>
> class Person < ActiveRecord::Base
>   has_one :address, :dependent => :destroy, :inverse_of => :person
> end
>
> class Address < ActiveRecord::Base
>   belongs_to :person, :inverse_of => :address
> end
>
> Here are my questions:
>
> Are these class definitions set up the right way?

Hobo does not support has-one relationships completely. So if you
want the Hobo magic you have to use has_many and then constrain N to
[0,1] via validations.

Or just move all of the address fields into User.

P.S. good call using inverse_of. It's not strictly necessary in
Hobo but probably would have been if Hobo was first built in 2010
instead of 2007. :)

Bryan

Bryan Larsen

unread,
Feb 27, 2012, 10:24:52 AM2/27/12
to Peter Pavlovich, Hobo Users
On Mon, Feb 27, 2012 at 10:14 AM, Peter Pavlovich <pavl...@gmail.com> wrote:
> Hi again!
>
> So, is there any fundamental reason why hobo doesn't have good support for
> "has_one" relationships? Or was it just that there wasn't time in the
> schedule? I only ask because perhaps I might investigate adding/enhancing
> that support as a contribution to the project. If so, perhaps we can chat
> about what this would entail?

There are two large pieces that would need to be done:

either add has-one support to [accessible
associations](http://cookbook.hobocentral.net/manual/multi_model_forms)
or rip accessible associations out of hobo and rearchitect hobo to use
accepts_nested_attributes_for. The latter is the right thing to do,
the former would be easier.

and

an input-one tag.

>
> In the interim, when you say "constrain N to [0,1] via validations", can you
> point me to an example I can study?

http://apidock.com/rails/ActiveModel/Validations/ClassMethods/validates_length_of

Bryan

Reply all
Reply to author
Forward
0 new messages