私はHTML
スニペットを持っています
<div class="playlist" id='{{ playlist.name }}'>
{{ playlist.name }}
<button class="btn btn-primary queueAll" href="#">queue all</button>
<i class="icon-chevron-right icon-large"></i>
</div>
および対応するjQuery
関数として
$(function(){
$('#playlist').click(function(){
$.ajax({
url: '/getUserPlaylists',
success: function(response, textStatus, jqXHR){
// console.log(response);
$('#feature').empty().append(response);
},
error: function(response, textStatus, jqXHR) {
bootstrap_alert.error('error in receving playlists');
}
});
});
});
私が欲しいもの
- ユーザーが
queue all
ボタンをクリックすると、alert
ポップアップが表示され、何も起こりません
そのための私のjQuery
機能は
$(function(){
$('body').on('click', '.queueAll', function(e) {
e.preventDefault();
alert('will queue all videos');
});
});
今何が起きているのですか?
私はそうしますalert
'will queue all videos'
が、最初の関数にリストされているように ajax 呼び出しを行いjQuery
、次のページに結果をロードします
期待どおりに機能しないのはどうしてe.preventDefault()
ですか?