Skip to content

Commit

Permalink
Added some data check
Browse files Browse the repository at this point in the history
  • Loading branch information
micc83 committed Apr 22, 2014
1 parent 8be02d2 commit 98694a9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions jquery.edittable.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
for (a = 0; a < crow; a += 1) {
buildRow(data[a], s.headerCols.length).appendTo($table.find('tbody'));
}
} else {
// Variable columns
} else if ( data[0] ) {
// Variable columns
for (a = 0; a < data[0].length; a += 1) {
$table.find('thead tr').append(defaultth);
}
Expand Down Expand Up @@ -124,7 +124,12 @@
// Fill the table with data from textarea or given properties
if ($el.is('textarea')) {

reset = JSON.parse($el.val());
try {
reset = JSON.parse($el.val());
} catch (e) {
reset = {};
}

$el.after($table);

// If inside a form set the textarea content on submit
Expand Down

0 comments on commit 98694a9

Please sign in to comment.