Skip to content

Instantly share code, notes, and snippets.

@tkosuga
Last active December 17, 2015 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkosuga/5584607 to your computer and use it in GitHub Desktop.
Save tkosuga/5584607 to your computer and use it in GitHub Desktop.
twitter bootstrapでのajaxなmodalの説明
<div class="modal-header" style="padding-bottom: 0; ">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon-remove"></i></button>
<ul class="nav nav-tabs" id="<%= detail.object_id %>_tab" style="padding-bottom: 0px; margin-bottom: 0px;">
<li><a href="#<%= detail.object_id %>_all" data-toggle="tab">全て</a></li>
<li><a href="#<%= detail.object_id %>_have_comment" data-toggle="tab">コメントあり</a></li>
</ul>
</div>
<div class="modal-body">
<% bookmarks = detail.bookmarks %>
<div class="tab-content">
<div id="<%= detail.object_id %>_all" class="tab-pane">
<%= render :partial => "comments_panel", :locals => {:bookmarks => (bookmarks || [])} %>
</div>
<div id="<%= detail.object_id %>_have_comment" class="tab-pane">
<%= render :partial => "comments_panel", :locals => {:bookmarks => (bookmarks || []).reject{|bookmark| bookmark.comment.blank?}} %>
</div>
</div>
</div>
<script>
$('#<%= detail.object_id %>_tab').on('shown', function (e) {
e.target; // activated tab
})
$('#<%= detail.object_id %>_tab a:first').click(function (e) {
e.preventDefault();
$(this).tab('show');
})
$('#<%= detail.object_id %>_tab a:last').click(function (e) {
e.preventDefault();
$(this).tab('show');
})
$('#<%= detail.object_id %>_tab a:first').tab('show');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment