Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Bug Reports » Application Crashes Due to Duplicated Concurrent INSERT Transactions
jQuery Solution: Application Crashes Due to Duplicated Concurrent INSERT Transactions [message #5919 is a reply to message #5888] Sat, 01 October 2016 03:08 Go to previous messageGo to previous message
kong is currently offline  kong
Messages: 90
Registered: December 2011
Member
Using jQuery it is quite effective to disable a button after the first click and show a spinner to indicate that the application is processing the request.

For those interested, let me summarize:

1) Get an image file for the spinner you like to use and save to radicore/css/ folder. Attached is the image I used (spin-red.svg).

2) Download jQuery file from https://jquery.com/download/ and save to radicore/javascript/ folder. Attached is the jQuery file I used (jquery-3.1.1.min.js).

3) For each module that you would like to implement this solution for, add the following to the module's style_custom.css file:
.loadingspinner
{
    background:
        url("../css/spin-red.svg")
        no-repeat
        center center;
}

4) Add the following to the *.class.inc files of the tables you need this solution for (Also check you have fixed http:// radicore.org/fud/index.php?t=msg&th=2299&start=0& ;)
    function _cm_setJavaScript ($javascript)
        // insert any javascript to be included in the <HEAD> or <BODY> elements.
    {
        $javascript['head'][]['file'] = '../javascript/jquery-3.1.1.min.js';

        $javascript['foot'][]['code'] =  "
            $('form :submit').click( 
                function () { 
                    \$(this).
                    addClass('loadingspinner').
                    prop('disabled', true).
                    closest('form').
                    append(\$('<input/>', {
                        type: 'hidden', 
                        name: this.name, 
                        value: this.value
                    })).
                    submit();
                }
            );";

        return $javascript;

    } // _cm_setJavaScript

That's all, enjoy!

References:
http:// stackoverflow.com/questions/22509343/prevent-double-form-sub mission
http:// stackoverflow.com/questions/12837335/how-to-display-loading- spinner-in-a-textbox-on-clicking-of-a-button

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Localization of task_desc in workitem
Next Topic: Outer Database Popup File Missing
Goto Forum:
  


Current Time: Fri Nov 22 01:49:43 EST 2024

Total time taken to generate the page: 0.03729 seconds