Skip to content

Instantly share code, notes, and snippets.

@imasif
Last active August 29, 2015 14:09
Show Gist options
  • Save imasif/5d01e4a32fc3d6022fd7 to your computer and use it in GitHub Desktop.
Save imasif/5d01e4a32fc3d6022fd7 to your computer and use it in GitHub Desktop.
<!-- 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