简体   繁体   中英

jQuery UI Dialog Buttons won't hide

Somehow this code doesn't work properly. All Buttons are shown, only the "Generate" Button hides after the sucessful link generation. On the same site I have another dialog, implement the same way, which is working fine.

 $("#guest-link-dialog").dialog({ autoOpen: false, resizable: false, height: 300, width: 510, modal: true, draggable: false, closeOnEscape: false, open: function() { $("#closeButton").hide(); }, buttons: [{ id: 'generateButton', text: 'Generieren', click: function() { $('#generatedlink').html('<img src="<?php echo Yii::app()->request->baseUrl; ?>/images/icons/32x32/loading.gif" alt="loading" style="padding-left:215px;padding-top:40px;" />'); $.getJSON('<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=ajax/guestlink&fileid=' + $(this).data('fileid') + '&count=' + $('#inputcount').val()) .done(function(json) { if (json.status == "SUCESS") { $('#generatedlink').html('<a href="' + json.url + '" >' + json.url + '</a>'); $('#generateButton').hide(); $('#cancelButton').hide(); $('#closeButton').show(); } else if (json.status == "ERROR") { $("#message").css('color', 'red'); } $("#message").text(json.message); }) .fail(function(json) { $("#message").css('color', 'red'); $("#message").text('Fehler'); }); } }, { id: 'closeButton', text: 'Schliessen', click: function() { $(this).dialog('close'); } }, { id: 'cancelButton', text: 'Abbrechen', click: function() { $(this).dialog("close"); } }], close: function() { $("#message").css('color', ''); $('#generatedlink').html(''); $('#generateButton').show(); $('#cancelButton').show(); $('#closeButton').hide(); } }); 

Edit:

 <div id="guest-link-dialog" title="Gast Link erstellen"> <form> <fieldset style="border:1;"> <label for="count">Anzahl m&ouml;gliche Downloads</label> <input type="text" name="count" id="inputcount" class="text ui-widget-content ui-corner-all" size="1" value="1" maxlength="1" /> </fieldset> </form> <div id="generatedlink" style="width:100%"></div> </div> 

The problem was, the Button IDs were already used by the other Dialog. Giving them other IDs solves the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM