Skip to content

Wrap all text references with $.trim() to remove spaces from cell values. #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions jquery.tabledit.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ if (typeof jQuery === 'undefined') {

$td.each(function() {
// Create hidden input with row identifier.
var span = '<span class="tabledit-span tabledit-identifier">' + $(this).text() + '</span>';
var input = '<input class="tabledit-input tabledit-identifier" type="hidden" name="' + settings.columns.identifier[1] + '" value="' + $(this).text() + '" disabled>';
var span = '<span class="tabledit-span tabledit-identifier">' + $.trim($(this).text()) + '</span>';
var input = '<input class="tabledit-input tabledit-identifier" type="hidden" name="' + settings.columns.identifier[1] + '" value="' + $.trim($(this).text()) + '" disabled>';

// Add elements to table cell.
$(this).html(span + input);

// Add attribute "id" to table row.
$(this).parent('tr').attr(settings.rowIdentifier, $(this).text());
$(this).parent('tr').attr(settings.rowIdentifier, $.trim($(this).text()));
});
},
editable: function() {
Expand All @@ -111,7 +111,7 @@ if (typeof jQuery === 'undefined') {

$td.each(function() {
// Get text of this cell.
var text = $(this).text();
var text = $.trim($(this).text());

// Add pointer as cursor.
if (!settings.editButton) {
Expand Down Expand Up @@ -139,7 +139,7 @@ if (typeof jQuery === 'undefined') {
input += '</select>';
} else {
// Create text input element.
var input = '<input class="tabledit-input ' + settings.inputClass + '" type="text" name="' + settings.columns.editable[i][1] + '" value="' + $(this).text() + '" style="display: none;" disabled>';
var input = '<input class="tabledit-input ' + settings.inputClass + '" type="text" name="' + settings.columns.editable[i][1] + '" value="' + $.trim($(this).text()) + '" style="display: none;" disabled>';
}

// Add elements and class "view" to table cell.
Expand Down Expand Up @@ -256,7 +256,7 @@ if (typeof jQuery === 'undefined') {
// Get input element.
var $input = $(this).find('.tabledit-input');
// Get span text.
var text = $(this).find('.tabledit-span').text();
var text = $.trim($(this).find('.tabledit-span').text());
// Set input/select value with span text.
if ($input.is('select')) {
$input.find('option').filter(function() {
Expand All @@ -282,7 +282,7 @@ if (typeof jQuery === 'undefined') {
var $input = $(this).find('.tabledit-input');
// Set span text with input/select new value.
if ($input.is('select')) {
$(this).find('.tabledit-span').text($input.find('option:selected').text());
$(this).find('.tabledit-span').text($.trim($input.find('option:selected').text()));
} else {
$(this).find('.tabledit-span').text($input.val());
}
Expand Down
Loading