├── .travis.yml ├── Gruntfile.js ├── README.md ├── bower.json ├── build └── table-edits.min.js ├── index.html ├── package.json ├── src └── table-edits.js └── test ├── jasmine.html └── table-edits.spec.js /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.12" 4 | before_install: 5 | - npm install -g grunt-cli 6 | install: 7 | - mkdir travis-phantomjs 8 | - wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 9 | - tar -xvf $PWD/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 -C $PWD/travis-phantomjs 10 | - export PATH=$PWD/travis-phantomjs:$PATH 11 | - npm install 12 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = function(grunt) { 3 | grunt.initConfig({ 4 | pkg: grunt.file.readJSON('package.json'), 5 | uglify: { 6 | build: { 7 | files: { 8 | 'build/<%= pkg.name %>.min.js': 'src/table-edits.js' 9 | } 10 | } 11 | }, 12 | jasmine: { 13 | test: { 14 | src: 'src/table-edits.js', 15 | options: { 16 | vendor: 'node_modules/jquery/dist/jquery.js', 17 | specs: ['test/table-edits.spec.js'] 18 | } 19 | } 20 | } 21 | }); 22 | 23 | grunt.loadNpmTasks('grunt-contrib-uglify'); 24 | grunt.loadNpmTasks('grunt-contrib-jasmine'); 25 | 26 | grunt.registerTask('default', ['uglify']); 27 | }; 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## $.Table Edits 2 | 3 | [](https://travis-ci.org/nathancahill/table-edits) 4 | [](https://raw.githubusercontent.com/nathancahill/table-edits/master/build/table-edits.min.js) 5 | 6 | Table Edits is a lightweight jQuery plugin for making table rows editable. Built as minimally as possible so it's easy to extend. [Demo](http://nathancahill.github.io/table-edits/) 7 | 8 | __Table Edits__ only does a couple things: 9 | 10 | - Replaces cell values with input fields on edit 11 | - Handles row editing state 12 | - Fires callbacks for edit, save and cancel 13 | 14 | And __optionally__, a couple more: 15 | 16 | - Binds a button or double click to start editing 17 | - Binds enter and escape keys to save and cancel 18 | - Maintains column widths when switching to edit 19 | - Create select fields instead of input fields 20 | 21 | #### Options 22 | 23 | ``` 24 | $("table tr").editable({ 25 | keyboard: true, 26 | dblclick: true, 27 | button: true, 28 | buttonSelector: ".edit", 29 | dropdowns: {}, 30 | maintainWidth: true, 31 | edit: function(values) {}, 32 | save: function(values) {}, 33 | cancel: function(values) {} 34 | }); 35 | ``` 36 | 37 | #### Markup 38 | 39 | The only additional markup __Table Edits__ requires is a `data-field` attribute on each editable cell with it's column name: 40 | 41 | ``` 42 |