ページに次のようなjQuery関数を呼び出すボタンがあります。
$('[id^=edit]').one('click',function (){
id = $(this).attr('id')
changedId = id.replace('edit', '') // cut off the word 'edit'
oldValue = $('#' + changedId).text()
$('#' + changedId).html("<input class='myInput' type='text' value='" + oldValue +"'/>");
$(this).addClass('success');
$(this).attr('id', changedId+'Button');
$(this).text("save it")
});
基本的に、このクリックは段落内に入力要素を作成し、ボタンに別のクラスを追加してから、そのIDを変更します。
新しいIDのボタンがクリックされたときに実行される2番目の関数を作成したいと思います。例えば:
$('[id$=Button]').click(function(){
alert("it works");
});
このようなことは可能ですか?その新しい関数は私のDjangoアプリへのAJAX呼び出しをトリガーしますが、それは関係ありません。