Forum: Ruby on Rails Prototype ajax/javascript q

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fe28b992079d698249db5a6a4ce124dd?d=identicon&s=25 Constantin Gavrilescu (Guest)
on 2006-03-13 08:58
(Received via mailing list)
I'm trying to send to my application the coords x,y on an "input type
image" in a html form, but x,y variables are not present in the
POST_DATA (are not submitted). Any other field (hidden inputs) are being
sent when I click on the image input form field.

I use rails 1.0 and prototype 1.4, browsers Seamonkey
2.0, Firefox 1.x and Konqueror, Linux, and I'm just a newbie in ror.

Html code generated by rails:
<form action="/pixel/set" method="post" onsubmit="
new Ajax.Updater('coords', '/pixel/set', {asynchronous:true,
evalScripts:true, parameters:Form.serialize(this)}); return false;">
    <div><input name="matrix" type="image" src="/images/all.png"
/></div>
</form>

In POST_DATA I have ''.



Tried it without ajax:
<form action="/pixel/set" method="post">
<div id="pixels">
    <div><input name="matrix" type="image" src="/images/all.png"
    /></div>
</form>

In POST_DATA i have matrix.x=572&matrix.y=443.


Hints, anyone? The code in the rhtml template is:

<%= form_remote_tag(:update => "coords",
                     :url => { :action => "set" }) %>
<div id="pixels">
     <div><input name="matrix" type="image" src="/images/all.png"
     /></div>
<%= end_form_tag %>
531eb73f8fbf05a197721d02b4e6aadb?d=identicon&s=25 Bogdan Ionescu (Guest)
on 2006-03-13 15:02
(Received via mailing list)
My guess is that Form.serialize (in prototype.js) ignores <input
type="image">
You could modify Form.Element.Serializers (input) and add the desired
behaviour for type "image"

Bogdan
Fe28b992079d698249db5a6a4ce124dd?d=identicon&s=25 Constantin Gavrilescu (Guest)
on 2006-03-13 20:12
(Received via mailing list)
Cam pe la 03/13/2006 04:00 PM, Bogdan Ionescu scrise:
> My guess is that Form.serialize (in prototype.js) ignores <input
> type="image">
> You could modify Form.Element.Serializers (input) and add the desired
> behaviour for type "image"

Your guesss is be right. But after some reading, i found out that x,y
coordinates of the click are not available in the forms objects, so
can't use <input type="image">. I'll try something else.

Form.Element.Serializers = {
  input: function(element) {
    switch (element.type.toLowerCase()) {
      case 'submit':
      case 'hidden':
      case 'password':
      case 'text':
        return Form.Element.Serializers.textarea(element);
      case 'checkbox':
      case 'radio':
        return Form.Element.Serializers.inputSelector(element);
    }
    return false;
  },


--
They say money can't buy happiness? Look at the smile on my face... ear
to ear, baby!
This topic is locked and can not be replied to.