Last active
August 29, 2015 14:09
-
-
Save imasif/5d01e4a32fc3d6022fd7 to your computer and use it in GitHub Desktop.
MockJax Example with Bootstrap 3.2. JSfiddle Example: http://jsfiddle.net/asif097/yvkx1cLt/. Found this quick solution here: http://stackoverflow.com/questions/26064307/trigger-ajax-action-when-click-on-button-inside-dropdown-without-closing-it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- MockJax example with Bootstrap 3.2 --> | |
<script> | |
/**** MockJax to mock up an ajax response **/ | |
$.mockjax({ | |
url: '/like', | |
responseTime: 1000, | |
responseText: { | |
status: 'success', | |
fbStatus: 'liked' | |
} | |
}); | |
$('.dropdown-menu > li > a').click(function(event){ | |
event.stopPropagation(); | |
$.ajax({ url: '/like', | |
success: function() { | |
$('#likelink').html('<span class="glyphicon glyphicon-ok"></span> Liked!'); | |
} | |
}); | |
}); | |
</script> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.5.3/jquery.mockjax.js"></script> | |
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> | |
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/> | |
<!-- Single button --> | |
<div class="btn-group"> | |
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> | |
Like This <span class="caret"></span> | |
</button> | |
<ul class="dropdown-menu" role="menu"> | |
<li><a href="#" id="likelink">Like</a></li> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment