From e53a175740794162c2ffdb4029278d4e7473ebb2 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sat, 17 Nov 2012 12:04:29 -0600 Subject: [PATCH] better list widget, thanks Howesc --- VERSION | 2 +- gluon/sqlhtml.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index cfe0199f..86dad217 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.2.1 (2012-11-17 11:46:41) stable +Version 2.2.1 (2012-11-17 12:04:25) stable diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index eda4d05f..4db3d62c 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -263,16 +263,19 @@ class ListWidget(StringWidget): jQuery.fn.grow_input = function() { return this.each(function() { var ul = this; - jQuery(ul).find(":text").after('+').keypress(function (e) { return (e.which == 13) ? pe(ul) : true; }).next().click(function(){ pe(ul) }); + jQuery(ul).find(":text").after('+ -').keypress(function (e) { return (e.which == 13) ? pe(ul, e) : true; }).next().click(function(e){ pe(ul, e) }).next().click(function(e){ rl(ul, e)}); }); }; -function pe(ul) { +function pe(ul, e) { var new_line = ml(ul); rel(ul); - new_line.appendTo(ul); + new_line.insertAfter($(e.target).parent()); new_line.find(":text").focus(); return false; } +function rl(ul, e) { + $(e.target).parent().remove(); +} function ml(ul) { var line = jQuery(ul).find("li:first").clone(true); line.find(':text').val('');