1

ユーザーとコミュニケーションをとるためのさまざまなバブルを作成するメカニズムとして、BeautyTipsを使用しています。たとえば、詳細情報を含むバブルを表示するヘルプアイコンがあります。また、BTを使用してエラーメッセージと警告メッセージを表示します。

これが実際にはどのように見えるかです。

エラーメッセージの大部分は互いに積み重ねられています。

エラーメッセージが積み重ねられ、親メッセージが枯渇していることがわかります。

form_validatorには、errorPlacement引数の関数があります。

    errorPlacement: function (er, el) {
        if (el && el.length > 0) {
            if (el.attr('id') == 'ContractOpenEnded') {
                createErrorBubble($('#contractDuration'), er.text())
            }
            else {
                createErrorBubble($(el), er.text());
            }
        }
    }

これらの泡を作成するために重い物を持ち上げる関数は次のとおりです。

function createErrorBubble(element, text) {    
    // In a conversation with pcobar the spec was changed for the bubbles to be to the right of the element
    createBubble(element, text, 2, "none", "right", "#fe0000", "#b2cedc", "#ffffff", true);
    element.btOn();
}

ここではcreateBubble関数です。

function createBubble(element, content, messageType, trigger, positions, fillColor, strokeColor, foreColor, useShadow) {
    var btInstance = element.bt(
        content,
        {
            trigger: trigger,
            positions: positions,
            shrinkToFit: true,
            spikeLength: 12,
            showTip: function (box) {
                $(box).fadeIn(100);
            },
            hideTip: function (box, callback) {
                $(box).animate({ opacity: 0 }, 100, callback);
            },
            fill: fillColor,
            strokeStyle: strokeColor,
            shadow: useShadow,
            clickAnywhereToClose: false,
            closeWhenOthersOpen: false, // Closing when others open hides page validation errors. This should be false.
            preShow: function (box) {
                if (messageType != 1) return;

                var whiteboard = $($(box).children()[0]);
                var content = whiteboard.html();

                if (content.substr(0, 5).toLowerCase() == "<div>") {
                    content = content.substr(5, content.length -11);
                }

                whiteboard.html('<div><span class="helpWarningPrefix">Warning:</span> ' + content + "</div>");
            },
            cssStyles: { color: foreColor },
            textzIndex: 3602, // z-index for the text
            boxzIndex: 3601, // z-index for the "talk" box (should always be less than textzIndex)
            wrapperzIndex: 3600
        });
}

この質問への答えは私を惑わしています。

アップデート:

これは実際には、ページの表示可能領域にないものに対してバブルを作成しようとすることの問題のように見えます。

編集:問題の名前をより明確に反映するようにタイトルを更新しました。

4

1 に答える 1

0

以前のアップデート(画面外の要素にある問題)からの認識で、私は問題を「修正」するハックを思いつきましたが、私の猫がクラフトキラキラに入って何もなかったので、エレガントではなく、最高のものとはほど遠いです何が起こったのか考えてください。

これがハックです:

errorPlacement: function (er, el) {
    if (el && el.length > 0) {
        if (el.attr('id') == 'ContractOpenEnded') {
            $('#contractDuration').focus();
            createErrorBubble($('#contractDuration'), er.text())
        }
        else {
            $(el).focus();
            createErrorBubble($(el), er.text());
        }
    }
},

ここでの魔法は、要素をビューポートに戻すための.focus()呼び出しです。

于 2011-08-31T20:45:54.157 に答える