jQuery UI dialog buttons click once -


i have jquery dialog buttons. when user clicks on button, take time, make ajax call , stuff. during time, user able click again , again. want avoid behaviour.

i know, jquery has method one(). want. how achieve on dialog buttons?

my current code is:

$d.dialog({     buttons: [         {             text: "potrdi",             click: function() {                 // stuff             }         }     ] }); 

you can set button disabled using jquery-ui button's disabled option:

button( "option", "disabled", true ); 

here example of how set correctly on clicked button (the button enabled again after 2 secons):

$( function() {    $( "#dialog-confirm" ).dialog({      resizable: false,      height: "auto",      width: 400,      modal: true,      buttons: {        "delete items": function(e) {          btn = $(e.toelement).button( "option", "disabled", true );          settimeout(function() {            btn.button("option", "disabled", false );          }, 2000);        },        cancel: function() {          $( ).dialog( "close" );        }      }    });  } );
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">  <link rel="stylesheet" href="/resources/demos/style.css">  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>  <div id="dialog-confirm" title="empty recycle bin?">    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:12px 12px 20px 0;"></span>these items permanently deleted , cannot recovered. sure?</p>  </div>    <p>sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. donec aliquet leo vel magna. phasellus rhoncus faucibus ante. etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros lectus.</p>


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -