1

ユーザーが入力フォームで国の名前を変更した後に実行される jQuery セレクターがあります。ただし、国フィールドが変更された後、住所入力フィールドが変更され、ページ全体がリロードされることなく動的に更新されます。

質問: インライン/部分ページ更新後に、JQuery アクセス/新しい入力フィールドへのセレクターの伝達を行うにはどうすればよいですか?

例:

jQuery('[id^="Country"]').on('mouseup', function(e) {
// code gets here okay... the problem is it doesn't call the the following after the page refresh... 
});

jQuery('select[id^="AccountEditForm.Parent Ship To Address."]:visible,input[id^="AccountEditForm.Parent Ship To Address."]:visible').on('mousedown', function(e) {
// code no longer gets here because the input fields are updated dynamically for some reason
});

注: .live()... を使用していましたが、これは jQuery の新しいバージョンではサポートされなくなりました。

V$H.

4

1 に答える 1

1
$(document).on('mouseup', '[id^="Country"]',  function(e){
    alert($(this).attr('id'));
​});​

for(i=1;i<6;i++)
{
    var div=$("<div id='Country"+i+"'>country"+i+"</div>");
    $('#wrapper').append(div);
}

$('#wrapper').on('mouseup', '[id^="Country"]', function(e){
    alert($(this).attr('id'));
});

于 2012-04-14T13:34:29.047 に答える