1

私は奇妙な問題を抱えています。バグかどうかはわかりません。しばらくの間、それを修正して回避策を見つけようとしましたが、今のところ何も機能しません。誰かが私を助けてくれることを願っています。少し早いですがお礼を。

問題の説明 select2 ボックスにいくつかの文字を入力すると、一致するリストが表示されました。2 つ以上の文字を削除した後、リストから一致するものを選択します。その瞬間、ページが動かなくなりました。参照が失われました。唯一の解決策は、ページ全体を更新することです。

ajax 呼び出しは正常に機能し、select2 ボックスは変更ごとに更新されます。Enter キーを押すと、onchange 関数 (csjs) が実行されます。すべての関数の後にデバッグ メッセージが Java コンソールに表示されるため、すべての関数が動作しているように見えます。

私のコード

                        <xp:scriptBlock id="scriptBlock3">
                            <xp:this.value><![CDATA[

                var executeOnServer = function ( eventId ) {

// must supply event handler id or we're outta here....

if (!arguments[0])

    return false;

// OPTIONAL - The Client Side ID that you want to partial refresh after executing the event handler
var refreshId = (arguments[1]) ? arguments[1] : "@none";
var form = (arguments[1]) ? XSP.findForm(arguments[1]) : dojo.query('form')[0];

// OPTIONAL - Options object containing onStart, onComplete and onError functions for the call to the

// handler and subsequent partial refresh

var options = (arguments[2]) ? arguments[2] : {};

// OPTIONAL - Value to submit in $$xspsubmitvalue. can be retrieved using context.getSubmittedValue()

var submitValue = (arguments[3]) ? arguments[3] : '';

// Set the ID in $$xspsubmitid of the event handler to execute

dojo.query('[name="$$xspsubmitid"]')[0].value = eventId;

dojo.query('[name="$$xspexecid"]')[0].value = "";

dojo.query('[name="$$xspsubmitscroll"]')[0].value = "0|0";

dojo.query('[name="$$xspsubmitvalue"]')[0].value = submitValue;

XSP._partialRefresh("post", form, refreshId, options);}

x$("#{id:inputTextNieuweStudent}")
.select2({
        placeholder: "Selecteer een student",
        minimumInputLength: 3,
        quietMillis: 750,
        width: '400px',            
        ajax: {
                url: "/Apps/FEZ/SBA.nsf/selecteerStudent.xsp",  
                dataType: 'json',
                data: function (term, page) {
                return {
                    q: term, // search term
                    page_limit: 10,
                    local : true
                };
            },
            results: function (data, page) { // parse the results into the format expected by Select2.
                return data;
            }
        }

})
.on("change", 
    function(e) {
        console.log("changed to " + e.val);
        executeOnServer("#{id:voegToeStudent}", "#{id:lijstStudentSelectie}", {});
    } 
);
   ]]></xp:this.value>
                        </xp:scriptBlock>
                        </xp:inputText>
4

0 に答える 0