I''m atm programming a webform that allows users to order different
flyers with various sizes etc, now this is all dynamically updated
(meaning Flyer X can have Sizes A,B,C while Flyers Y can have Sizes
A,B,D,F).
How ever it''s also possible to select different options, options like
cutting/rounding to edit the end product, these options cost extra and
need to be calculated into the price. These options are listed as a list
of Check boxes called:
options_ids[]
Meaning if i submit the form i end up with an array called
"options_ids"
which i can get all the information from i need. Now the problem i have
is that i need to "send" this array before the form is submited to
calculated the price (which is dependant on Size, Product, Quantity and
Options) Now since the other options are dropdown boxes i can simply
send the value along in in ajax statement as follows:
<%= observe_field("format[id]",
:frequency => 0.25,
:update => "infoprijs",
:url => { :action => :getprijs },
:with => "''format_id=''+encodeURIComponent(value)+
''&quantity=''+encodeURIComponent($(''quantity[id]'').value)+
''&product=''+encodeURIComponent($(''product[id]'').value)")
%>
Now to add the options i thought i had to add the following (which is
clearly wrong since ruby keeps hating me for it)
''&options_ids='' +(''options_ids[]'')
Since i couldn''t find any documentation about passing an array through
ajax i hope one of the guru''s on these forums could help me out.
Thanks in advance,
F.B. ten Kate
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> <%= observe_field("format[id]", > :frequency => 0.25, > :update => "infoprijs", > :url => { :action => :getprijs }, > :with => "''format_id=''+encodeURIComponent(value)+ > ''&quantity=''+encodeURIComponent($(''quantity[id]'').value)+ > ''&product=''+encodeURIComponent($(''product[id]'').value)") %> > > Now to add the options i thought i had to add the following (which is > clearly wrong since ruby keeps hating me for it)Perhaps I''m missing the point, but couldn''t you use Form.serialize? e.g. <%= observe_field("format[id]", :frequency => 0.25, :update => "infoprijs", :url => { :action => :getprijs }, :with => "Form.serialize(''form-name'')" %> -- Ryan Dahl --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ry wrote:> > Perhaps I''m missing the point, but couldn''t you use Form.serialize? > e.g. > <%= observe_field("format[id]", > :frequency => 0.25, > :update => "infoprijs", > :url => { :action => :getprijs }, > :with => "Form.serialize(''form-name'')" %> > > -- > Ryan DahlHmm if i could get that working that would indeed be an ideal solution, i''ve been trying to get it working for a couple of hours now but for some reason i get a javascript error. Telling me that javascript is expecting a ''}'' which effectivly tells me nothing, i read around a bit aswell but haven''t found any one having any problems so i''m guesing im making some real novice mistake but what that mistake is i have no idea yet. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you do a view source on your generated page to see what the generated Javascript is, you should be able to spot the stray or missing "}". After a few times, you''ll almost get used to parsing all of the }''s and )''s. :). Wes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wes Gamble wrote:> If you do a view source on your generated page to see what the generated > Javascript is, you should be able to spot the stray or missing "}". > After a few times, you''ll almost get used to parsing all of the }''s and > )''s. :). > > WesThat''s kinda the problem, if i go down the steps..>> Select a Product type >> Select a ProductThe source isn''t changed when i go to "View >> Source" i get a lovely text file with nothing in it except the first ajax statement. (which is getting the different products for the selected product type) So i actually have no way (atleast as far as i can tell) to find where the error is coming from, the only thing i could imagen is that there is some HTML error in my form which is making Form.serialize it''s job impossible and trowing me this error. I''ve spend most of my day on this one line of code and im starting to get depressed :P -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
F.B. ten Kate wrote:> The source isn''t changed when i go to "View >> Source" i get a lovely > text file with nothing in it except the first ajax statement. (which is > getting the different products for the selected product type) > > So i actually have no way (atleast as far as i can tell) to find where > the error is coming from, the only thing i could imagen is that there is > some HTML error in my form which is making Form.serialize it''s job > impossible and trowing me this error. I''ve spend most of my day on this > one line of code and im starting to get depressed :PWhat I mean is to inspect your call since I was assuming that''s where the problem was. Do you use Firebug? It''s a plugin for Firefox that will let you monitor your XHR type requests and look at the response. It is invaluable when debugging AJAX code. You should be able to see your problem right away if you use it. Wes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wes Gamble wrote:> What I mean is to inspect your call since I was assuming that''s where > the problem was. > > Do you use Firebug? It''s a plugin for Firefox that will let you monitor > your XHR type requests and look at the response. It is invaluable when > debugging AJAX code. You should be able to see your problem right away > if you use it. > > WesOwkay, thanks for the tip, ill try it first thing tomorow ill let you know if i find the problem/what the problem is :) Thanks a bunch! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Owkay so i had another go, first thing i noticed is since i never loaded
the page in firefox (yes yes i know.. shame shame... i recently formated
and hadn''t bothered installing it yet! >.<) That the page
wasn''t working
at all for me...
And well since i got rather fed up with my own messy programming i
rewrite all the views to actually use the FormTagHelper, having done
this my views etc now looking alot cleaner i went back to trying to get
the darn thing to Form.serialize...
The lovely plugin/addon you suggested (firebug) gave me the following
message:
missing } after property list
prototype.js?1163... (line 181)
new Form.Element.Observer(''format[id]'', 0.25,
function(element, value)
{new Ajax.Updater(''infoprijs'',
''/bestel/test'', {asynchronous:true,
evalScripts:true,
parameters:''Form.serialize(''bestel'')='' +
value})})
Basically the same problem i already had, so ill keep bashing my head
against this, if you have any other suggestions please keep them coming
since i have the feeling i''ll be stuck on this for a while >.<
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
<%= observe_field("format[id]",
:frequency => 0.25,
:update => "infoprijs",
:url => { :action => :getprijs },
:with => "Form.serialize(''form-name'')" %>
The above stuff missed a bracket at last!
Try this...
<%= observe_field("format[id]",
:frequency => 0.25,
:update => "infoprijs",
:url => { :action => :getprijs },
:with => "Form.serialize(''form-name'')" )
%>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Kiran Soumya wrote:> <%= observe_field("format[id]", > :frequency => 0.25, > :update => "infoprijs", > :url => { :action => :getprijs }, > :with => "Form.serialize(''form-name'')" %> > > > The above stuff missed a bracket at last! > > Try this... > > <%= observe_field("format[id]", > :frequency => 0.25, > :update => "infoprijs", > :url => { :action => :getprijs }, > :with => "Form.serialize(''form-name'')" ) %>Ye thx, i noticed my code is the following: <%= observe_field("format[id]", :frequency => 0.25, :update => "infoprijs", :url => { :action => :test }, :with => "Form.serialize(''bestel'')") %> Which does have the bracket you mentioned, sadly it doesn''t see to be such an easy bracket missing problem :( -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Owkay, i have no idea why...
But after messing around with this for far to long... I finally found
the problem about 15 minutes ago...
the code has to be..
<%= observe_field("format[id]",
:frequency => 0.25,
:update => "infoprijs",
:url => { :action => :test },
:with => "formdata =
Form.serialize(''bestel'')") %>
Notice the formdata variable getting the Form.serialize data assigned, i
dont know why but all of the sites i spend hours on trying to find the
solution listed it as
:with => "Form.serialize(''form'')"
Well if any one out there is bashing his/her head against the same
problem... just assign add a variable...
I just knew it had to be some shitty easy to solve thing.... >.<
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
########################
### NEXT PROBLEM! :D ###
########################
Owkay, next problem :D still an ajax/form problem so ill keep it in here
(hoping people will read it anyway)
I have a list of multiple options users can select, with checkboxes! (i
could make it a select list but i think that''s an ugly way to do it in
this case) Now the check boxes are called:
option_ids[], this for the simple reason that i want ruby to get a nice
array of the different option id''s a user has selected. Now i also want
the price to be calculated when a user selectes (or deselects) an
option, now i tried to do that with...
<%= observe_field("option_ids[]",
:frequency => 0.25,
:update => "infoprijs",
:url => { :action => :test },
:with => "formdata =
Form.serialize(''bestel'')") %>
Because the X amount of checkboxes are all called option_ids[] it only
observes the first checkbox, is there a way to get around this? I could
ofc name the fields differently like option_ids[1], option_ids[X] etc
etc.. But this would call for an X amount of observers, which i
personally think is an unwanted solution. Any of you RoR gods have any
briliant solutions for me maybe? :)
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Spend a some hours on the problem but i''m really not getting anywhere. And yes this was a shameless bump! :x -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---