0

When a row's select button is clicked, a confirmation box pops up.

Upon confirming the box, the select-button shall become disabled, and a message is appended that shall fade out.

Both, button disabling and message appending work but only for a second. The button does not remain disabled. Also the message appends correctly but only for a second too.

I could change the fadeOut(Int) to any Integer but still the message only shows up for a second. Why does functionality only work for a second?

<script>
    $('#button_<?php echo $platform->id; ?>').click(function() {
        var choice = confirm('Please confirm that you wish to do the following Platform: <?php echo $platform->company; ?>');
        if (choice == true) {
            $('#button_<?php echo $platform->id; ?>').prop("disabled", true);
            $('.job_confirm').css('visibility', 'visible');
            $('.job_confirm').append('The Job has been added to your Userarea -->');
            $('.job_confirm').fadeOut(5000);
        }
    });
</script> 
4

1 回答 1

5

尝试event.preventDefault();

<script type="text/javascript">

        $('#button_<?php echo $platform->id; ?>').click(function(event) {

        event.preventDefault();
        var choice = confirm('Please confirm that you wish to do the following Platform: <?php echo $platform->company; ?>');
        if (choice == true) {
            $('#button_<?php echo $platform->id; ?>').prop("disabled", true);
            $('.job_confirm').css('visibility', 'visible');
            $('.job_confirm').append('The Job has been added to your Userarea -->');
            $('.job_confirm').fadeOut(5000);
        }
        });

</script> 
于 2013-09-02T07:09:16.973 回答