1

私はjsTreeを使用しており、2つのテキストボックスがあります:

<input type="text" id="previous_tree_id" value="" /><hr />
<input type="text" id="current_tree_id" value="" />

私が持っているjsTreeコールバックで:

$("#demo_1").tree({    
    callback : {
        onselect : function (NODE, TREE_OBJ) {
            var selected_tree_id = $(NODE).attr('id');
            $("#current_tree_id").val(selected_tree_id);
        }
    }
});

私の問題は

前に選択したツリー アイテムの ID を previous_tree_id テキスト ボックスに入力するにはどうすればよいですか? 私のツリーIDは単なる数字で、3つのツリーアイテムがあります。

ツリー ID: 1、2、3

たとえば、3 つのツリー アイテムがあり、最初のツリー アイテムを最初に選択すると、次のようになります。

アクション: - ツリー ID 1 を選択

出力: - textbox previous_tree_id = 1 - textbox current_tree_id = 1

その後、ツリー ID 2 を選択します。

アクション: - ツリー ID 2 を選択

出力: - textbox previous_tree_id = 1 - textbox current_tree_id = 2

その後、ツリー ID 3 を選択します。

アクション: - ツリー ID 3 を選択

出力: - textbox previous_tree_id = 2 - textbox current_tree_id = 3

私が解決しなければならないのは単なるjavascriptロジックですか、それとも参照/以前に選択したツリー項目を取得するためのjsTree関数がありませんか?

前もって感謝します。- マーク

4

1 に答える 1

1

ジョジョの助けを借りて問題が解決しました。

$("#demo_1").tree({    
    callback : {
        onselect : function (NODE, TREE_OBJ) {
            var selected_tree_id = $(NODE).attr('id');

            // update first the previous_tree_id textbox
            $("#previous_tree_id").val(current);
            // store the new selected tree id in the current_tree_id
            $("#current_tree_id").val(selected_tree_id);
        }
    }
});
于 2010-06-04T08:16:38.563 に答える