From 827e663ac48db7c9c694b46bdc6d049211a5412d Mon Sep 17 00:00:00 2001 From: niphlod Date: Mon, 21 Sep 2015 22:18:18 +0200 Subject: [PATCH] better list: widget --- applications/welcome/static/js/web2py-bootstrap3.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/welcome/static/js/web2py-bootstrap3.js b/applications/welcome/static/js/web2py-bootstrap3.js index 2e702cc3..4716f44a 100644 --- a/applications/welcome/static/js/web2py-bootstrap3.js +++ b/applications/welcome/static/js/web2py-bootstrap3.js @@ -18,9 +18,9 @@ function pe(ul, e) { var new_line = ml(ul); rel(ul); - if ($(e.target).parent().is(':visible')) { + if ($(e.target).closest('li').is(':visible')) { /* make sure we didn't delete the element before we insert after */ - new_line.insertAfter($(e.target).parent()); + new_line.insertAfter($(e.target).closest('li')); } else { /* the line we clicked on was deleted, just add to end of list */ new_line.appendTo(ul); @@ -30,9 +30,9 @@ } function rl(ul, e) { - if ($(ul).children().length > 1) { + if ($(ul).find('li').length > 1) { /* only remove if we have more than 1 item so the list is never empty */ - $(e.target).parent().remove(); + $(e.target).closest('li').remove(); } } @@ -46,9 +46,9 @@ function rel(ul) { /* keep only as many as needed*/ $(ul).find("li").each(function() { - var trimmed = $.trim($(this.firstChild).val()); + var trimmed = $.trim($(this).find(":text").val()); if (trimmed == '') $(this).remove(); - else $(this.firstChild).val(trimmed); + else $(this).find(":text").val(trimmed); }); } var ul = this;