Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <table id='table'></table>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
         <form class="form-horizontal">
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 1</label>
              <div class="col-sm-10">
                  <input type="text" class="form-control" name="col1" id="col1">
              </div>
           </div>
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 2</label>
              <div class="col-sm-10">
                  <input type="text" class="form-control" name="col2" id="col2">
              </div>
           </div>
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 3</label>
              <div class="col-sm-10">
                  <input type="text" class="form-control" name="col3" id="col3">
              </div>
           </div>
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 4</label>
              <div class="col-sm-10 radio">
                <label class="radio-inline"> 
                  <input type="radio" name="col4" value="0"> 0
                </label>
                <label class="radio-inline"> 
                  <input type="radio" name="col4" value="1"> 1
                </label>
              </div>
           </div>
           <div class="form-group">
              <label class="col-sm-2 control-label">Col 5</label>
              <div class="col-sm-10">
                  <input type="text" class="form-control" name="col5" id="col5">
              </div>
           </div>
         </form>
      </div>

      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                .update, .remove {
  margin-left: 5px;
  margin-right: 5px;
}

.remove {
  color: rgba(215,38,54,0.85);
}
              
            
!

JS

              
                // buid data for table
function buildTable(cells, rows) {
    var i, j, row,
        data = [];

    for (i = 0; i < rows; i++) {
        row = {};
        row['col1'] = 'col1 - ' + i;
        row['col2'] = 'col2 - ' + i;
        row['col3'] = 'col3 - ' + i;
        row['col4'] = i%2;
        row['col5'] = 'col5 - ' + i;
        data.push(row);
    }
    return data;
}

// show the data of table in the modal
function showModal($modal, row) {
  // row is the data for the specific row of the table  
    for (var name in row) {
        $modal.find('input:not([type=radio],[type=checkbox])[id="' + name + '"]').val(row[name]);
        $modal.find('input:radio[name="'+name+'"][value="' + row[name] + '"]').attr('checked', true)
    }
    $modal.modal('show');
}

// format of update or delete icons
function actionFormatter(value) {
    return [
        '<a class="update" href="javascript:void(0)" title="修改"><i class="glyphicon glyphicon-edit"></i></a>',
        '<a class="remove" href="javascript:void(0)" title="删除"><i class="glyphicon glyphicon-remove-circle"></i></a>',
    ].join('');
};

var $modal = $('#myModal');

// updata & delete events
window.actionEvents = {
    'click .update': function (e, value, row) {
        showModal($modal, row);
    },
  
    'click .remove': function (e, value, row) {
        if (confirm('really want to delete?')) {
            // ajax delete
        }
    }
};

// modal when hidden, clear the form
$modal.on('hidden.bs.modal', function(event) {
        $modal.find("input:not([type=radio],[type=checkbox]),textarea,select").val('');
        $modal.find('input[type=checkbox], input[type=radio]').prop('checked', false);       
    });

var tableSetting = {
    striped: true,
    pagination: true,
    search: true,
    showToggle: true,
    showRefresh: true,
    showPaginationSwitch: true,
    minimumCountColumns: 2,
    showHeader: true,
    showFooter: true,
    classes: 'table table-hover table-condensed',
    columns: [{
        field: 'col1',
        title: 'Col 1',
        class: '',
    }, {
        field: 'col2',
        title: 'Col 2',
        class: '',
    }, {
        field: 'col3',
        title: 'Col 3',
        class: '',
    }, {
        field: 'col4',
        title: 'Col 4',
        class: '',
    }, {
        field: 'col5',
        title: 'Col 5',
        class: '',
    }, {
                title: 'operation',
                field: 'action',
                width: '7%',
                align: 'center',
                formatter: actionFormatter,
                events: actionEvents
            }],
};

$(function() {
    $('#table').bootstrapTable(tableSetting);
    $('#table').bootstrapTable('load', buildTable(8, 20));
});

$(window).on('resize', function() {
    $('#table').bootstrapTable('resetView');
});


              
            
!
999px

Console