Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

[Free Nodelet Hack] Disable Submit Button on Click

by haukex (Archbishop)
on Mar 25, 2017 at 13:43 UTC ( [id://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 (Saint) 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 (Saint) 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
Domain Nodelet?
Node Status?
node history
Node Type: monkdiscuss [id://1185885]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-24 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found