Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
117 lines (91 sloc) 3.57 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xml:lang="en" xmlns="">
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>Tab based modal</title>
<script type="text/javascript" src="//"></script>
<script type="text/javascript" src="//"></script>
<script type="text/javascript" src="//"></script>
<!-- Adding Backbone.Modal extension here -->
<link type="text/css" rel="stylesheet" href="/backbone.modal.css">
<link type="text/css" rel="stylesheet" href="/backbone.modal.theme.css">
<script type="text/javascript" src="/backbone.modal.js"></script>
<!-- Custom style -->
<link type="text/css" rel="stylesheet" href="/examples/css/style.css">
<a href="#" class="open">Open modal</a>
<div class="app"></div>
<!-- The modal structure, with an container element that will contain all tabs -->
<script type="text/template" id="modal-template">
<div class="bbm-modal__topbar">
<li class="bbm-modal__tab"><a href="#" id="tab1" class="active">General</a></li>
<li class="bbm-modal__tab"><a href="#" id="tab2">Account</a></li>
<div class="my-container"></div>
<div class="bbm-modal__bottombar">
<a href="#" class="bbm-button">Done</a>
<!-- Tab 1 -->
<script type="text/template" id="modal-view1-template">
<div class="bbm-modal__section">
<h3>Tab based example</h3>
<p>It's also really easy to create a modal, with seperate views that you can control using tabs.</p>
<p>We're also using a default style, but you can overwrite anything you want.</p>
<!-- Tab 2 -->
<script type="text/template" id="modal-view2-template">
<div class="bbm-modal__section">
Your account details
jQuery(function($) {
// Create a modal view class
var Modal = Backbone.Modal.extend({
template: _.template($('#modal-template').html()),
viewContainer: '.my-container',
submitEl: '.bbm-button',
views: {
'click #tab1': {
name: 'tab1',
view: _.template($('#modal-view1-template').html()),
onActive: 'setActive'
'click #tab2': {
name: 'tab2',
view: _.template($('#modal-view2-template').html()),
onActive: 'setActive'
// views: [{
// name: 'tab1',
// view: _.template($('#modal-view1-template').html()),
// onActive: 'setActive'
// },{
// name: 'tab2',
// view: _.template($('#modal-view2-template').html()),
// onActive: 'setActive'
// }],
setActive: function(options) {
this.$('.bbm-modal__tab a').removeClass('active');
$('.open').on('click', function(){
// Render an instance of your modal
var modalView = new Modal({name: 'tab2'});
<!-- Do not include in your page -->
<script src="//localhost:35729/livereload.js"></script>