0

jquery.keypad.js を使用して、ユーザーが選択できるテキスト ボックスに特殊文字 (ÁÃÅÀ...) を表示しています。テキストボックスの最初のフィールドは正常に機能していますが、「さらに追加」ボタンをクリックして同じテキストフィールドを追加しても機能しません。機能していないのに、「さらに追加」をクリックした後、もう一度関数を呼び出しています。問題は何ですか?

$(function () {
        $('.keypadactive').keypad({keypadClass: 'flatKeypad',keypadOnly: false, 
             layout: [<? echo  utf8_encode("'ÁÃÅÀÂÄááåàâ䯿ßÇçÐÉËÈÊéëèê', 'ÌÎÍÏìîíïÑñÒÔÖØÓÕðòôöøóõÚÜÙ' ,'ÛùûúüÝýÿÿ¡,°¹²³º¼½¾±µ', '£¥\$¢þ§©®¯·¨¬«»¦ª¶'");?> ], prompt: '',showOn: 'button', buttonImageOnly: true, buttonImage: 'images/spl.jpg'});
});

$('.add_more').live('click',function(){
    $(this).parent().parent().parent().parent().append($('#add_me_next').html());
    $(this).parent().html('<label class="w50">&nbsp;</label><input type="button" name="remove" value="Remove" class="button remove" />');

    setTimeout('keypadCall()',1000);

});

function keypadCall(){
    $('.keypadactive').keypad({keypadClass: 'flatKeypad',keypadOnly: false, 
                 layout: [<? echo  utf8_encode("'ÁÃÅÀÂÄááåàâ䯿ßÇçÐÉËÈÊéëèê', 'ÌÎÍÏìîíïÑñÒÔÖØÓÕðòôöøóõÚÜÙ' ,'ÛùûúüÝýÿÿ¡,°¹²³º¼½¾±µ', '£¥\$¢þ§©®¯·¨¬«»¦ª¶'");?> ], prompt: '',showOn: 'button', buttonImageOnly: true, buttonImage: 'images/spl.jpg'});
}
4

1 に答える 1

0

DOM の準備ができたときに利用可能だった最も近い親、またはハンドラーを使用した$(document)それ自体へのイベント委任を試してください。.on()

$(document).on('click', '.add_more', function(){
    $(this).parent().parent().parent().parent().append($('#add_me_next').html());
    $(this).parent().html('<label class="w50">&nbsp;</label><input type="button" name="remove" value="Remove" class="button remove" />');

    setTimeout(keypadCall,1000);

});

()のfromkeypadCall関数を削除してみてくださいsetTimeout()

于 2013-04-09T05:53:40.097 に答える