При открытии диалогового окна jQuery-UI, как я могу скрыть кнопку (например, скрыть кнопку «Сохранить»)?Как скрыть диалоговые кнопки при открытии диалогового окна jQuery-ui
http://jsfiddle.net/ba6jwh54/1/
<!-- head -->
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/ui-lightness/jquery-ui.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js" type="text/javascript"></script>
<!-- body -->
<div id="dialog" class="dialog" title="My Title"></div>
<a href="#" id="open">open</a>
// javascript
$(document).ready(function() {
$('#open').click(function() {
$("#dialog").dialog("open");
});
$("#dialog").dialog({
autoOpen: false,
height: 400,
width: 350,
modal: true,
open: function() {
var dialog = $(this);
console.log('dialog', dialog);
var buttons = dialog.dialog("option", "buttons");
console.log('buttons', buttons);
//Change names this way...
buttons[0].text = 'Save2';
buttons[1].text = 'Cancel2';
dialog.dialog("option", "buttons", buttons);
//How do I hide a button (i.e. hide Save button)?
},
buttons: [{
text: 'SAVE',
click: function() {
alert('save');
$(this).dialog("close");
}
}, {
text: 'CANCEL',
click: function() {
$(this).dialog("close");
}
}]
});
});
А, я вижу. Спасибо. Любопытно, почему нельзя манипулировать объектом кнопки, чтобы сделать это? – user1032531
Объект кнопок не относится к кнопкам HTML внутри диалогового окна. Это относится к параметрам, используемым для создания (или восстановления) кнопок. –
Gotcha! Еще раз спасибо – user1032531