Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

[Free Nodelet Hack] Disable Submit Button on Click

by haukex (Prior)
on Mar 25, 2017 at 13:43 UTC ( #1185885=monkdiscuss: print w/replies, xml ) Need Help??

Disabling submit buttons on click is pretty common nowadays I think, adding the following to the Free Nodelet Settings enables this behavior for the "preview" and "create" buttons (using jQuery). Because disabled buttons don't get included in form submissions, but PerlMonks relies on them, I added a workaround which adds a <input type="hidden" ...>.

<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script language="javascript" type="text/javascript"> //<!-- $(document).ready(function() { $("input[type='submit'][name='op'][value='preview'], " +"input[type='submit'][name='op'][value='create']") .click(function() { $(this).prop("disabled",true); $(this).after( $('<input>').attr({ type: 'hidden', name: $(this).attr('name'), value: $(this).attr('value') }) ); }); }); //--> </script>

Replies are listed 'Best First'.
Re: [Free Nodelet Hack] Disable Submit Button on Click
by LanX (Chancellor) on Mar 25, 2017 at 14:22 UTC
    > Disabling submit buttons on click is pretty common nowadays

    OK, but what for? :)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      OK, but what for? :)

      Preventing double form submissions - I was inspired by Double posting, although now (after the updates) it sounds like that is a different problem.

        I'm pretty sure that clicking [create] again before the last submit finished doesn't cause harm.

        Will test it here ...

        Oops ... nope I can't test reliably because of my own wiki nodelet hack.

        Anyone? :)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

        I'm pretty sure that clicking [create] again before the last submit finished doesn't cause harm.

        Will test it here ...

        Oops ... nope I can't test reliably because of my own wiki nodelet hack.

        Anyone? :)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

        I'm pretty sure that clicking [create] again before the last submit finished doesn't cause harm.

        Will test it here ...

        Oops ... nope I can't test reliably because of my own wiki nodelet hack.

        Anyone? :)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

Re: [Free Nodelet Hack] Disable Submit Button on Click
by LanX (Chancellor) on Mar 25, 2017 at 15:55 UTC
    This might prove useful if the button stays disabled after going back in history.

    Like this people might be stopped from accidentally posting mutants ( ie edited clones which are mostly duplicates)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://1185885]
Approved by Athanasius
help
Chatterbox?
[hippo]: Marketing should not be allowed near such utilities.
[Corion]: I should tell them about the "dim+lock all monitors to show the immediate alert centered" feature of that software so they can announce the next intranet website feature even better ;)

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (16)
As of 2017-05-24 14:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?