Observe two forms, submit both in one action?

Hi All,

I currently have a RoR website that lists music gigs. By default it
displays all results in the database over several pages, but the results
can be filtered using a simple form - it may be easier to see it at
http://www.gigcatcher.com

So far, this all works fine and the form is watched every second for
changes by observe_form.

The problem begins when I try to add a drop-down list… Unless no
frequency is set on observe_form, the behaviour of the drop-down is not
really what I want (i.e. just hovering over a selection submits the
form).

What I would like:
The existing search boxes for artist, venue and town - observed every
second
A drop-down list (for gigs added in the last x days) - submitted on
selection

Is it possible to have two forms on the page, observed separately but
which each submit the combined data from both?

Cheers!

  • Sandy

Sandy T. wrote:

Hi All,
Is it possible to have two forms on the page, observed separately but
which each submit the combined data from both?
Cheers!

  • Sandy

Try use something like :with=>“Form.serialize(‘form1_id’) &
Form.serialize(‘form2_id’)”

Regards
Simo
addsw.it

just to fix, the correct syntax is
:with=>“Form.serialize(‘form1_id’) + ‘&’+ Form.serialize(‘form2_id’)”

You can also use only one form, using different observe_field (for
artist, venue, town and gigs ) with option
:with=>“data=Form.serialize(‘form1_id’)”

Simo
addsw.it

Sandy T. wrote:

Try use something like :with=>“Form.serialize(‘form1_id’) &
Form.serialize(‘form2_id’)”

Hmm… I had a go at that but no luck, I’ve gone with the odd behaviour
on the drop-down as it only seems to affect firefox from what I can see.
I reduced the observe time to 2 seconds also which makes it less
noticeable.

Shout if anyone knows a better way to do this…

Cheers,

  • Sandy

Try use something like :with=>“Form.serialize(‘form1_id’) &
Form.serialize(‘form2_id’)”

Hmm… I had a go at that but no luck, I’ve gone with the odd behaviour
on the drop-down as it only seems to affect firefox from what I can see.
I reduced the observe time to 2 seconds also which makes it less
noticeable.

Shout if anyone knows a better way to do this…

Cheers,

  • Sandy

Simo wrote:

just to fix, the correct syntax is
:with=>“Form.serialize(‘form1_id’) + ‘&’+ Form.serialize(‘form2_id’)”

You can also use only one form, using different observe_field (for
artist, venue, town and gigs ) with option
:with=>“data=Form.serialize(‘form1_id’)”

Simo
addsw.it

Cheers Simo! much appreciated - I now have two forms that submit with
data from both.

If anyone is wanting the same thing, I just created two forms and two
observe_form functions (one observing by time and one observing on
select, for the drop-downs). For each observe_form I included the
following line:

:with=>“data=Form.serialize(‘form1_id’) + ‘&’ +
Form.serialize(‘form2_id’)”

(I had to combine the syntax from above a little to include ‘data=’)

Cheers!

  • Sandy

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs