I have a HTML
snippet as
<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>
and corresponding jQuery
function as
$(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');
}
});
});
});
What I want
- When user clicks on
queue all
button,alert
should pop up and nothing happens afterwords
my jQuery
function for that is
$(function(){
$('body').on('click', '.queueAll', function(e) {
e.preventDefault();
alert('will queue all videos');
});
});
whats happening now?
I do ge the alert
'will queue all videos'
but it then makes the ajax call as listed in first jQuery
function and loads the next page with results
How is it that e.preventDefault()
is not working as expected?