-1

So I made a game and in my game there is a activation part of items. So they may click activate button many times like a spam and it causes some bugs. Any idea how I can avoid it?

This activation part is not like a submit form, its just like they click it and this function works and activates the thing. Any suggestions what I can do about it?

This is how they activate

https://ibb.co/iOZNr6

and php part is like this inside. so this clicking part is inside in php.

  if($idd->is_active == 0){

            echo "<a href='/item/activate/".$s."'>Aktifleştir</a>";
        }
        elseif($idd->is_active == 1){
            echo '<a href="/item/de-activate/'.$s.'">Pasifleştir</a>';
        }
Berke
  • 81
  • 2
  • 12

1 Answers1

1

This is example how to prevent jQuery events from firing multiple times

HTML:

<!DOCTYPE html>
<html>
<head>
    <title>jQM Complex Demo</title>
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>    
</head>
<body>
    <div data-role="page" id="index">
        <div data-theme="a" data-role="header">
            <h3>
                First Page
            </h3>
            <a href="#second" class="ui-btn-right">Next</a>
        </div>

        <div data-role="content">
            <a data-role="button" id="test-button">Click me</a>
        </div>

        <div data-theme="a" data-role="footer" data-position="fixed">

        </div>
    </div> 
    <div data-role="page" id="second">
        <div data-theme="a" data-role="header">
            <h3>
                Second Page
            </h3>
            <a href="#index" class="ui-btn-left">Back</a>
        </div>

        <div data-role="content">

        </div>

        <div data-theme="a" data-role="footer" data-position="fixed">

        </div>
    </div>    


</body>
</html>   

JS:

    $(document).on('pageinit', '#index', function(){       
        $(document).on('click', '#test-button',function(e) {
            alert('Button click');
        }); 
    });
Adam Kozlowski
  • 5,606
  • 2
  • 32
  • 51