Hi mailing list! I''m currently working on a web mapping application and now trying to ajaxify it, using Prototype of course. The great problem now is, that I''m using input type="image" fields to determine where the user clicked on my map. Usually (in non-ajax requests), the browser manages to submit two variables for one input field: name_x and name_y for the X and Y coordinates. And that''s the point.. I need to serialize the form of course, before submitting it using Ajax, but how do I serialize an image input field? There is no serializer for that in the library yet and the default way using Form.Element.Serializers.textarea does not work at all of course.. It only delivers an empty value! As I don''t really want to calculate the coordinates myself using strange offset calculations and mouse event handlers or something like that, I would be very glad if someone knew a solution for that. Thank you so far Pascal --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Off the top of my head, you could use Event.observe(<image input field>, "click", foobar) and the foobar() function should give you the ability to get the x,y position of the click an then put it them in hidden form fields or send them to the server to be stored in the session or what have you. -- Dash -- Pascal Ehlert wrote:> Hi mailing list! > I''m currently working on a web mapping application and now trying to > ajaxify it, using Prototype of course. > > The great problem now is, that I''m using input type="image" fields to > determine where the user clicked on my map. > Usually (in non-ajax requests), the browser manages to submit two > variables for one input field: name_x and name_y for the X and Y > coordinates. > And that''s the point.. I need to serialize the form of course, before > submitting it using Ajax, but how do I serialize an image input field? > There is no serializer for that in the library yet and the default way > using Form.Element.Serializers.textarea does not work at all of > course.. It only delivers an empty value! > > As I don''t really want to calculate the coordinates myself using > strange offset calculations and mouse event handlers or something like > that, I would be very glad if someone knew a solution for that. > > Thank you so far > > Pascal > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Well, what exactly do you mean by ''should give you the ability''? ;) I think the issue is how to actually determine the positions.. If I knew that, I could even write my own serializer and submit them in a non-standard way (with name as the variable name and x-cord_y- cord as the value for example). Pascal On Mar 2, 10:17 pm, David Dashifen Kees <dashi...-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> wrote:> Off the top of my head, you could use Event.observe(<image input field>, > "click", foobar) and the foobar() function should give you the ability > to get the x,y position of the click an then put it them in hidden form > fields or send them to the server to be stored in the session or what > have you. > > -- Dash -- >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Go to this page: http://prototypejs.org/api/event And check out the observe(), pointerX() and pointerY() functions. A combination of those to: 1. Add an event observe to your image input. 2. When an event is triggered, get the pointerX and pointerY values for where on the page things were clicked. 3. Use find the x,y coordinate of the image and convert from the page x,y to the image x,y and 4. Save those values in a way that you can serialize. On second thought, this seems like a lot of work, especially the conversion in #3. You should be able to use the page function (http://prototypejs.org/api/position/page) to get the x,y coordinates of the image element which''ll make the conversion easier. Hopefully someone else can help you out more because this would be a pain. If no one else responds and you still need some more explanation, I''ll try to work up an example page for you so you can see what I mean. -- Dash -- Pascal Ehlert wrote:> Well, what exactly do you mean by ''should give you the ability''? ;) > I think the issue is how to actually determine the positions.. > If I knew that, I could even write my own serializer and submit them > in a non-standard way (with name as the variable name and x-cord_y- > cord as the value for example). > > Pascal > > On Mar 2, 10:17 pm, David Dashifen Kees <dashi...-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> wrote: > >> Off the top of my head, you could use Event.observe(<image input field>, >> "click", foobar) and the foobar() function should give you the ability >> to get the x,y position of the click an then put it them in hidden form >> fields or send them to the server to be stored in the session or what >> have you. >> >> -- Dash -- >> >> > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you very much, but I wanted to avoid all that calculation stuff, as I said in my first post. ;-) I hope someone else has a cleaner and easier solution, otherwise I will do it that way. On Mar 2, 10:36 pm, David Dashifen Kees <dashi...-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> wrote:>> Pascal Ehlert wrote: > > Well, what exactly do you mean by ''should give you the ability''? ;) > > I think the issue is how to actually determine the positions.. > > If I knew that, I could even write my own serializer and submit them > > in a non-standard way (with name as the variable name and x-cord_y- > > cord as the value for example). > > > Pascal > > > On Mar 2, 10:17 pm, David Dashifen Kees <dashi...-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> wrote: > > >> Off the top of my head, you could use Event.observe(<image input field>, > >> "click", foobar) and the foobar() function should give you the ability > >> to get the x,y position of the click an then put it them in hidden form > >> fields or send them to the server to be stored in the session or what > >> have you. > > >> -- Dash -- > Go to this page:http://prototypejs.org/api/event > > And check out the observe(), pointerX() and pointerY() functions. A > combination of those to: > > 1. Add an event observe to your image input. > 2. When an event is triggered, get the pointerX and pointerY values for > where on the page things were clicked. > 3. Use find the x,y coordinate of the image and convert from the page > x,y to the image x,y and > 4. Save those values in a way that you can serialize. > > On second thought, this seems like a lot of work, especially the > conversion in #3. You should be able to use the page function > (http://prototypejs.org/api/position/page) to get the x,y coordinates of > the image element which''ll make the conversion easier. > > Hopefully someone else can help you out more because this would be a > pain. If no one else responds and you still need some more explanation, > I''ll try to work up an example page for you so you can see what I mean. > > -- Dash ----~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---