2

マウスリーブでボタンがアクティブなクラスを失うのを防ごうとしていますが、機能しません。

したがって、私のボタンはjQueryのbuttonset(). それらはボタンであり、チェックボックスではありません。チェックボックスが機能するには ID が必要なため、問題外です。

これは私のコードです:

$('.jquery_ui_buttonset', this.scope).buttonset();

$('.jquery_ui_buttonset > button', this.scope).each(function() {
    $(this).bind('mouseleave keyup mouseup blur', function(e) {
        if ($(this).hasClass('ui-state-persist')) {
            e.stopImmediatePropagation();
            if (e.type == 'blur') {
                $(this).removeClass('ui-state-focus');
            }
            $(this).removeClass('ui-state-hover');
        }
    });
});

ボタンにクラスがある場合、両方が明示的に削除されるまでクラスui-state-persistを失うべきではないという考えです。ui-state-activeアクティブなボタンの切り替えは、このハンドラーによるクリックで行われます。

CMSPage.prototype.switchEditTab = function(e) {
    if (e.data.params.id == null) {
        return;
    }

    $('.editor .body', this.scope).hide();
    $('.editor .header button', this.scope).removeClass('ui-state-active').removeClass('ui-state-persist');
    $('.editor .body[data-tab-id=' + e.data.params.id + ']', this.scope).show();
    $('.editor .header button[data-id=' + e.data.params.id + ']', this.scope)
        .addClass('ui-state-active').addClass('ui-state-persist');
}

e.stopPropagation()また、 andおよびそれらのすべての組み合わせを追加しようとしましe.preventDefault()たが、機能しません。そして、これとまったく同じコードが通常の UI ボタン​​ (ボタンセットにないもの) にも機能します。

どんな助けでも大歓迎です。

編集

私はまだこの問題を解決していません。私を助けてくれた皆さんに報奨金をあげたいのですが、私は新しいメンバーなのでできません。buttonset()チェックボックスではなく、永続的にアクティブなボタンを使用したいというこの問題に遭遇した人はいませんか?

4

0 に答える 0