blog@osd.se

Just another WordPress weblog
  • Home
  • About me
  • My website (in Swedish)

Prototype is a prototype?

August 13, 2007

In my quest to figure out why Prototype’s request method sent all my submit buttons, I stumbled upon this, not so pretty, piece of code:

if (value != null && (element.type != 'submit' || (!submitted &&
    submit !== false && (!submit || key == submit) && (submitted = true)))) {

It’s from a changeset in Prototype’s Trac page and is supposed to fix this bug.

The reason I started reading the code was that I’m using multiple submit tags with different names. Instead of just varying the value, I set the type tag to “submit”. Example:

<input name="create" value="Create New..." type="submit" />

and in Rails I check if params[:create] is set to see if that button was pressed or not. Perhaps this is really bad for some reason that I have missed, I don’t know (it does work in my version of IE6 aswell), but the fix doesn’t solve my problem. It just solves when using multiple input tags with the name submit and vary the name. The reason I don’t like looking what the value attribute is set to, is that it’s part of the design and should be free to change, without having to modify the controller. Of course, hidden values are always an alternative, but requiring Javascript to use a simple form seems wrong.

Anyway, I opened up my prototype.js and started reading the code and found the above piece of code. Note the assignment in the end of the second row. I think it’s intentional.

Categories
Programming, Rails, Web
Comments rss
Comments rss
Trackback
Trackback

« Helium Per-user tags with has_many_polymorphs »

Leave a Reply

Click here to cancel reply.

Categories

  • Games (4)
  • Music (7)
  • Programming (5)
  • Rails (4)
  • Stupid (1)
  • Swedish (2)
  • TV (1)
  • Uncategorized (1)
  • Web (4)

Links

  • 456 Berea Street
  • Ayende @ Rahien
  • Calle’s Journal
  • Discobelle
  • Manolo
  • Matthew Garrett’s Journal
  • Maximum Flow
  • Månhus (in Swedish)
  • My work
  • MySQL Performance Blog
  • ReadWriteWeb
  • Sphinx search engine
  • The Sartorialist

Archives

  • October 2009
  • December 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox