# tablesorter

## Content Editable

### Flexible client-side table sorting

Back to documentation

NOTE!

- This widget can not be applied to the original plugin and requires jQuery 1.7+ and a browser that supports `contenteditable` attributes (almost all modern browsers).
- Note: In Internet Explorer, please wrap the cell content with a DIV or SPAN as it is not possible to make table cells directly contenteditable. Wrapping the content in the markup is much more efficient than using javascript to do it for you (especially in IE).
- Updated v2.13.2, because of the limitation in IE, if a table cell contains any DIV or SPAN immediately inside the cell, it will be targeted instead of the table cell itself and made content editable. So, if you don't care about IE support, there is no need to include the extra markup.
- In some browsers, additional CSS is needed to highlight a focused editable table cell. See the CSS block below.
- Editable widget options include (defaults in parenthesis):
  - `editable_column` (`[]`) - Contains an array of columns numbers you want to have editable content (zero-based index). `contenteditable="true"` is added to cells within these columns.
  - `editable_enterToAccept` (`true`) - Makes the user press enter to accept the content within the editable table cell; if `false`, clicking outside the cell will accept the content.
  - `editable_autoResort` (`false`) - If `true` the column will resort (only if already sorted) after the content has been changed.
  - `editable_noEdit` (`'no-edit'`) - Class name on table cells to search for that are not to become editable. The search is only done within the columns set by the `editable_column` option.
- Pressing escape while editing will cancel any changes.
- In the demo below, click in any of the first three columns to edit the content, except for the cell containing "Peter".
- To prevent a table cell from becoming editable, add the class name `"no-edit"` to the cell.
- Edited content will be accepted in the following circumstances:
  - Pressing enter when the `editable_enterToAccept` option is `true`.
  - Clicking outside of the current editable content.
  - Moving the mouse outside of the current tbody. This is done because if the content editable is still active when the user clicks on the header to sort the column, all sorts of bad things happen.
- Edited content will not be accepted in the following circumstances:
  - Pressing Escape within the editable content.

# Demo

First Name | Last Name | Age | Total | Discount | Date
--- | --- | --- | --- | --- | ---
Peter | Parker | 28 | $9.99 | 20% | Jul 6, 2006 8:14 AM
John | Hood | 33 | $19.99 | 25% | Dec 10, 2002 5:14 AM
Clark | Kent | 18 | $15.89 | 44% | Jan 12, 2003 11:14 AM
Bruce | Almighty | 45 | $153.19 | 44% | Jan 18, 2001 9:12 AM
Bruce | Evans | 22 | $13.19 | 11% | Jan 18, 2007 9:12 AM

# Javascript

# CSS

# HTML