From fa2f2e7bed48c1f1fe88ae3bec60bae281e0d71d Mon Sep 17 00:00:00 2001 From: Sean Cuevo Date: Wed, 13 Jan 2016 13:31:47 -0700 Subject: [PATCH 1/2] adding support for inputs coded into the table --- mindmup-editabletable.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/mindmup-editabletable.js b/mindmup-editabletable.js index 36be540..8a12bbb 100644 --- a/mindmup-editabletable.js +++ b/mindmup-editabletable.js @@ -15,14 +15,18 @@ $.fn.editableTableWidget = function (options) { showEditor = function (select) { active = element.find('td:focus'); if (active.length) { - editor.val(active.text()) - .removeClass('error') - .show() - .offset(active.offset()) - .css(active.css(activeOptions.cloneProperties)) - .width(active.width()) - .height(active.height()) - .focus(); + if(active.find(':input').length){ + active.find(':input').focus(); + }else{ + editor.val(active.text()) + .removeClass('error') + .show() + .offset(active.offset()) + .css(active.css(activeOptions.cloneProperties)) + .width(active.width()) + .height(active.height()) + .focus(); + } if (select) { editor.select(); } @@ -111,6 +115,13 @@ $.fn.editableTableWidget = function (options) { }); element.find('td').prop('tabindex', 1); + element.find('td > :input').blur( function(){} ).keydown(function (e) { + if (e.which === ENTER || e.which === ESC ) { + $(this).parent('td').focus(); + e.preventDefault(); + e.stopPropagation(); + } + }); $(window).on('resize', function () { if (editor.is(':visible')) { From b81a8414cf59c2a56ea7e3a64602f1ba80d51595 Mon Sep 17 00:00:00 2001 From: Sean Cuevo Date: Wed, 13 Jan 2016 14:15:52 -0700 Subject: [PATCH 2/2] adding listeners to embedded inputs when focused in case you are adding additional rows --- mindmup-editabletable.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mindmup-editabletable.js b/mindmup-editabletable.js index 8a12bbb..dd08e8c 100644 --- a/mindmup-editabletable.js +++ b/mindmup-editabletable.js @@ -16,7 +16,13 @@ $.fn.editableTableWidget = function (options) { active = element.find('td:focus'); if (active.length) { if(active.find(':input').length){ - active.find(':input').focus(); + active.find(':input').focus().blur( function(){} ).keydown(function (e) { + if (e.which === ENTER || e.which === ESC ) { + $(this).parent('td').focus(); + e.preventDefault(); + e.stopPropagation(); + } + }); }else{ editor.val(active.text()) .removeClass('error') @@ -115,13 +121,6 @@ $.fn.editableTableWidget = function (options) { }); element.find('td').prop('tabindex', 1); - element.find('td > :input').blur( function(){} ).keydown(function (e) { - if (e.which === ENTER || e.which === ESC ) { - $(this).parent('td').focus(); - e.preventDefault(); - e.stopPropagation(); - } - }); $(window).on('resize', function () { if (editor.is(':visible')) {