Skip to content

Commit

Permalink
fixed bug where single quotes would cause only a portion of the curre…
Browse files Browse the repository at this point in the history
…nt cell value to be populated in the input
  • Loading branch information
ejbeaty committed Jun 3, 2016
1 parent 71fbb82 commit e1473e9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions js/dataTables.cellEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ jQuery.fn.dataTable.Api.register('MakeCellsEditable()', function (settings) {

var cell = table.cell(this).node();
var oldValue = table.cell(this).data();
// Sanitize value
oldValue = sanitizeCellValue(oldValue);

// Show input
if (!$(cell).find('input').length && !$(cell).find('select').length) {
// Input CSS
Expand Down Expand Up @@ -173,3 +176,12 @@ function getInputField(callingElement) {
}
return inputField;
}

function sanitizeCellValue(cellValue) {
if (typeof (cellValue) === 'undefined' || cellValue.length < 1) {
return "";
}
// escape single quote
cellValue = cellValue.replace(/'/g, "&#39;");
return cellValue;
}

0 comments on commit e1473e9

Please sign in to comment.