Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's what I came up with, which is adapted from above. Fixed so that it detects a cancelled event propagation using Prototype's stopped attribute.</p> <p>Other changes include using longer variable names (I always get confused about whether e is event or element), and a function that removed the replacement inputs if the form submission is cancelled. In my implementation pressing back on the browser doesn't show the page as it was when the user left it, instead it seems to be refetched (I'm using Rails), so I've removed that part too.</p> <p>I'm using buttons rather than inputs in my application so that part has changed also.</p> <pre><code>function replaceSubmit(event) { var element = event.element(); Element.insert(element, { 'before': '&lt;input type="hidden" name="' + element.name + '" value="' + element.value +'" class="button_replacement"&gt;'}); } function removeReplacementSubmits() { $$('input.button_replacement').each(function(button) { button.remove(); }); } function greySubmits(event) { // Don't disable the submit if the submit was stopped with a return(false) if (event.stopped === true) { removeReplacementSubmits(); } else { $$('button[type="submit"]').each(function(button) { button.disabled = true; button.innerHTML += '&amp;#133;'; }); } } Event.observe(window, 'load', function() { $$("button[type='submit']").each(function(element) { Event.observe(element, 'click', replaceSubmit); }); $$("form").each(function(element) { Event.observe(element, 'submit', greySubmits); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload