0

jsを介してSharePointPeopleEditorから入力値を取得する際に問題が発生しています。

通常、以下のコードを介してこのコントロールから値を取得できます。

 var user;
    var pe = document.getElementById('<%=peStaffAccount.ClientID %>').getElementsByTagName('div');
    var i;
    var peopleEnt;
    for (i in pe) {
        if (pe[i].id != null) {
            if (pe[i].id == 'divEntityData' && pe[i].description != null) {
                peopleEnt = pe[i]
            }
        }

    }
// this is the value from this textbox but only after we click checked user
alert(peopleEnt .description)

私の質問は、このテキストボックスに直接値を入力した場合、どうすればこの値を取得できますか?下の画像、私の入力値を参照してください..これを取得したい... ここに画像の説明を入力してください

4

3 に答える 3

1

Working with people picker in javascript is pretty awful. The actual control that you type into is really a content editable div. It will have an ID which is the ID of your control followed by _upLevelDiv. You will need to grab that and then parse what is within.

The code you posted is actually dealing with the nested divs created when an entity is resolved. These divs are contained within upLevelDiv.

スクリーンショットに示されているように、コントロールにテキストしかない場合は、非常に簡単です。テキストと解決されたエンティティが混在している場合は、divにテキストとhtmlの両方が含まれるため、より複雑になります。

注:上記のすべてはIEにのみ当てはまります。他のブラウザでは、テキストエリア(IEでは非表示)を使用します。

于 2011-07-20T20:52:24.137 に答える
0

質問を正しく理解したかどうかはわかりません。

KeyPressイベントをテキストボックスにバインドして、チェックされたユーザーボタンをクリックする前に入力中にテキストをリアルタイムで取得できるようにすることができます。

    yourTextField.onKeyPress = function(){
          var txt = yourTextField.value;
    }
于 2011-07-20T05:10:11.930 に答える
0

レンダリングされたページを調査するには、以下を使用します。

  1. 'View Source'を使用して、getElementById('<%= peStaffAccount.ClientID%>')がサーバーによって有効なClientIDで正しく置き換えられていることを確認します。

  2. Use the browser's debugger (F12 in IE9, Developer tools in Chrome) to inspect the DOM for the existence of the element by that ClientID

  3. Using the same tools, watch for any script error reported by the debugging tools (which are otherwise silently ignored by the browsers).

于 2011-07-20T20:46:31.427 に答える