2016-07-27 7 views
0

私はjqueryのappendメソッドを使用してフォームを追加し、この方法は.numerik_kontrolクラスを持っていますが、作業この機能は、別の形態であるが、それは私のダイナミックなフォームに取り組んでいない動的な数値形式制御問題

私の機能。

$(document).ready(function(){ 

    /** numerik kontrol*/ 
$(".numerik_kontrol").keydown(function (e) { 
     // Allow: backspace, delete, tab, escape, enter and . 
     if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || 
      // Allow: Ctrl+A, Command+A 
      (e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) || 
      // Allow: home, end, left, right, down, up 
      (e.keyCode >= 35 && e.keyCode <= 40)) { 
       // let it happen, don't do anything 
       return; 
     } 
     // Ensure that it is a number and stop the keypress 
     if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { 
      e.preventDefault(); 
     } 
    }); 
/** numerik kontrol bitiş*/ 

/** select seçim*/ 
$(".btn_ekle").on("click", function(e) { 
    var ekle = $(".ekle").html(); 
    $(".add_after").append(ekle).show(); 

    e.preventDefault(); 

}); 



$(document).on('change', '.havale_tipi', function() { 
    var value = $(this).val(), 
     parent = $(this).closest(".group"); 
    if (value == "iban_no") { 
     $(".hesaba_form", parent).fadeOut(); 
     $(".iban_no_form", parent).fadeIn(); 
    } else { 
     $(".iban_no_form", parent).fadeOut(); 
     $(".hesaba_form", parent).fadeIn(); 
    } 


}); 



$(document).on("click", ".iade_sil", function() { 

    var form_sil; 
    var form_sil = confirm("Formu silmek istediğinize emin misiniz ?"); 
    if (form_sil == true) { 
    $(this).closest(".group").remove(); 
    } else { 
     return false; 
    } 
}); 

document.getElementById('iade_miktari').className="numerik_kontrol"; 


}); 

if you wanna check out full click this link - demo page

フォームボタン(左ボタン)の下をクリックした場合、あなたはつもりダイナミックなフォームあなたの$(document).ready使用で

+1

私はあなたがあなたの '$(文書)後までのダイナミックフォームを作成していない賭ける.ready'が持っています'numerik_kontrol'要素はまだ存在しないので、イベントハンドラはそれらにアタッチされません。 – Tibrogargan

+0

私は自分のプロジェクトコードを追加してそこに見ることができます:) –

答えて

1

$(document).onイベントハンドラの代わりに、既存のnumerik_kontrol要素に​​ハンドラを参照してください。

$(".numerik_kontrol"),keydown(function(e) { ... 
:これは直接 $(document).ready

すなわち

の代わりに単一のセレクタ評価の結果にハンドラを結合するのではなく、文書にハンドラをバインドして、すべてのKeyDownイベントが発生したときに、セレクタを評価します

は、より多くのこのような何かを試してみてください。

$document.on("keydown", ".numerik_kontrol", function(e) { ... 
+0

あなたのおかげです。 –