1

fcbkcompleteの使用に興味があります。

  • onselect–アイテム選択時にイベントを発生させます。
  • onremove–アイテムの削除時にイベントを発生させる

これらの2つのイベントで発生したいのは、入力ボックス内のアイテムのID/値のリストにアラートを出すことです。

これらの値を取得する方法を理解するのを手伝ってもらえますか?

ありがとう

4

2 に答える 2

2

プラグインは内部selectの要素ではなく実際の要素に関連付けられているoptionため、親選択に含まれるオプションのすべてのオプションの詳細を警告する関数を記述できるはずです。多分次のようなものです:

$("#select").fcbkcomplete({
       onselect: function() {
           var optionList;
           $("option",this).each(function() {
               optionList += $(this).attr("id") + " : " + $(this).val() + "\n";
           });
           alert(optionList);
       }
});
于 2010-03-06T06:00:46.920 に答える
0

アイテムがDBに存在するかどうか、この場合はユーザーをチェックします。

$(document).ready(function () {
    $("#users").fcbkcomplete({
        json_url: "yoururl.php",
        cache: false,
        filter_case: false,
        filter_hide: true,
        complete_text:"'.get_lang('StartToType').'",
        firstselected: true,
        onselect:"check_users",   //<----- important
        filter_selected: true,
        newel: true
    });
});

ユーザーがDBに存在するかどうかを確認します

function check_users() {
    //selecting only "selected" users
    $("#users option:selected").each(function() {
        var user_id = $(this).val();        
        if (user_id != "" ) {            
            $.ajax({ 
                url: "my_other_url_to_check_users.php", 
                data: "user_id="+user_id,
                success: function(return_value) {
                    if (return_value == 0 ) {
                        alert("UserDoesNotExist");                        
                    }                    
                },            
            });                
        }        
    });
}
于 2011-04-27T09:04:28.273 に答える