JQueryUI.button () remains pressed after opening a ui dialog with it in firefox

link for jsfiddle: http://jsfiddle.net/6UWZQ/1

look at this direct link if you click on any line when deleting or editing and after canceling the click the button will remain highlighted (only in Firefox)

I make the buttons as follows:

$("input[type=submit]").addClass("abtn"); 
$("tbody a").addClass("abtn");
$(".abtn").button();

and I add a confirmation dialog for each form using the css class in the submit button, for example:

<script type="text/javascript">
        var currentFormconfirm;
        $(function () {
            $("#dialog-confirm-confirm").dialog({
            show: "drop",
            hide: "fade",
                resizable: false,
                height: 220,
                width: 400,
                modal: true,
                autoOpen: false,
                buttons: {
                    'Yes': function () {
                        $(this).dialog('close');
                        currentFormconfirm.submit();
                    },
                    'Cancel': function () {
                        $(this).dialog('close');
                    }
                }
            });
            $(".confirm").click(function () {
                currentFormconfirm = $(this).closest('form');
                $("#dialog-confirm-confirm").dialog('open');
                return false;
            });
        });

</script>
<div id="dialog-confirm-confirm" title="Confirm dialog">
    Are you sure you want to delete this foobar ?
</div>

and form:

<form action="/awesome/foobar/Delete/7" method="post" class="fr">
                    <input type="submit" class="confirm abtn ui-button ui-widget ui-state-default ui-corner-all" value="Delete" role="button" aria-disabled="false">
                    </form>
+3
source share
8 answers

jquery ui 1.8.1. . , ui-state-focus .

+4

, ...

, , $(document).ready

$("button, input[type='button'], input[type='submit']").button()
    .bind('mouseup', function() {
        $(this).blur();     // prevent jquery ui button from remaining in the active state
});
+7

Hoang , jquery ui, - removeClass onClick. :

button.click(function() {
    button.removeClass("ui-state-focus ui-state-hover");
}

, , : , , , .

+4

jquery-ui-1.8.7.custom.min.js jQuery UI Button

.bind("mouseup.button",function(){
    if(c.disabled)return false;
    a(this).removeClass("ui-state-active")
})

.bind("mouseup.button",function(){
    if(c.disabled)return false;
    a(this).removeClass("ui-state-active ui-state-hover ui-state-focus")
})
+1

I know this a bit later, but the problem still exists, and I made a real simple fix that calls the blur function on your button.

$('#myButton').blur();

You call the method blur()immediately after opening the dialog.

Here is a snippet:

$('#cbDate').button();
if(date == "infinite")
{
    $('#cbDate').checked = true;
    $('label[for=cbDate]').addClass('ui-state-active');
    //This is the interesting part
    $('#cbDate, label[for=cbDate]').blur();
}
else
{
    $('#cbDate, label[for=cbDate]').blur();
}
+1
source

since this is a jquery error, my solution is to do this instead of the button ():

   $(".abtn")
                .hover(function () { $(this).addClass("ui-state-hover"); },
                    function () { $(this).removeClass("ui-state-hover"); })
                .bind({ 'mousedown mouseup': function () { $(this).toggleClass('ui-state-active'); } })
                .addClass("ui-state-default").addClass("ui-corner-all")
                .bind('mouseleave', function() { $(this).removeClass('ui-state-active') });
0
source

How to add init to the dialog:

open: function() { $('.ui-button').blur(); }
0
source

In jQuery 1.8.17, the following works well:

$(document).ready(function() {

    ...

    $(".ui-button").live('click', function() {
        $(this).blur();
        $(this).removeClass("ui-state-focus ui-state-hover");
    });
})
0
source

Source: https://habr.com/ru/post/1768007/


All Articles