0

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?

4
  • 1
    Take a look here stackoverflow.com/questions/577548/… Commented Nov 18, 2013 at 12:58
  • @christiandev thanks so much for that link! Helped me through this! Commented Nov 18, 2013 at 13:01
  • When iam going to send them to the delete page should i use window location then or is there any other possibilities? Commented Nov 18, 2013 at 13:04
  • @Tommy it might be best to ask a new question.. You'll have a better chance of it being answered. People might not find your comment.. If you want to direct your comment at someone use the @ sign followed by their name like it I did at the first of this comment. Commented Nov 19, 2013 at 23:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.