iam using jQuery ui dialog widget and im now wondering if there is possible to hide/show a button?
My code looks like this atm:
$(document).ready(function() {
$( "#dialog" ).dialog({
open: function(event, ui) {
$(".ui-dialog-titlebar-close").hide();
$('.CoverBox').toggle();
},
close: function(event, ui) {
$(".CoverBox").toggle();
},
autoOpen: false,
position: ["top", 20],
draggable: false,
closeOnEscape: true,
width: 400,
minHeight: 100,
buttons: [
{
text: "Nej",
class: 'btn btn-sm btn-primary pull-right',
click: function() {
$( this ).dialog( "close" );
}
},
{
text: "Radera Kategorien",
class: 'btn btn-sm btn-danger pull-right',
click: function() {
alert('Fick med ett ID:' + $(this).data('catID'));
$( this ).dialog( "close" );
}
},
{
text: "Radera Allt",
class: 'btn btn-sm btn-danger pull-right',
click: function() {
alert('Fick med ett ID:' + $(this).data('catID'));
$( this ).dialog( "close" );
}
}
]
});
// Link to open the dialog
$( ".dialog-link" ).click(function( event ) {
$("#dialog").data('catID', $(this).attr('id'));
$.get("functions/getArticlesCat.php", { catID: $(this).attr('id') })
.done(function(data) {
if (data == 1) {
$(".alert-danger").html('Undersökte även denna kategorien, och det visar sig att den innehåller artiklar. Vill du radera allt eller bara kategorien?');
$(".alert-danger").show();
$("#dialog").dialog("open");
}
else {
$(".alert-danger").hide();
$("#dialog").dialog("open");
}
});
event.preventDefault();
});
});
The a:link iam clicking on is checking if there is articles in that category you are trying to delete.
And the thing i want to do is: If there is articles in the category show "Radera Allt" if not hide that button..
Is this possible?