This fixes a release-blocking issue where we weren't running client-side validation until _two_ characters were entered, and we were missing pasted text.
Thanks to bmclaughlin and jrist for assistance with debugging the JavaScript on this one!
-- Matt
Binding to 'keydown' was firing before the changed text was available, meaning that we wouldn't run validations until the second character was entered, and causing us to miss pasted text. This change should remedy both issues.
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=813924 --- .../views/deployments/launch_time_params.html.haml | 28 ++++++++++---------- 1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/app/views/deployments/launch_time_params.html.haml b/src/app/views/deployments/launch_time_params.html.haml index 7fcbe58..3ea2546 100644 --- a/src/app/views/deployments/launch_time_params.html.haml +++ b/src/app/views/deployments/launch_time_params.html.haml @@ -45,6 +45,18 @@ = submit_tag t('.finalize'), :class => 'button primary', :id => 'submit_params'
:javascript + function checkEnteredParams() { + $('.launch-time-params .parameters').each(function() { + var $parameters = $(this).find('.parameter input'); + var filledOut = _.all($parameters, function(item) { + return ! _.isEmpty($(item).val()); + }); + var param_id = $(this).attr('id'); + $('.labels').find('#' + param_id).toggleClass('filled-out', filledOut); + $('#submit_params').attr('disabled', !filledOut); + }); + }; + (function () { function selectService($service) { var old_param_id = $('.service.selected').attr('id'); @@ -60,25 +72,13 @@ .text($service.next('.description').text()); }
- function checkEnteredParams() { - $('.launch-time-params .parameters').each(function() { - var $parameters = $(this).find('.parameter input'); - var filledOut = _.all($parameters, function(item) { - return ! _.isEmpty($(item).val()); - }); - var param_id = $(this).attr('id'); - $('.labels').find('#' + param_id).toggleClass('filled-out', filledOut); - $('#submit_params').attr('disabled', !filledOut); - }); - } - var $services = $('.launch-time-params .services .labels h4.service'); selectService($services.first()); $services.live('click', function(e) { selectService($(this)); });
$('#submit_params').attr('disabled', true); - $('.parameter input').live('keydown', function(e) { - checkEnteredParams(); + $('.parameter input').live('keyup mouseup paste', function(e) { + setTimeout("checkEnteredParams()", 10) }); checkEnteredParams(); })();
ACK, patch works for me.
Mainn
----- Original Message -----
From: "Matt Wagner" matt.wagner@redhat.com To: aeolus-devel@lists.fedorahosted.org Sent: Wednesday, April 18, 2012 4:23:08 PM Subject: [PATCH conductor 0/1] #813924 - Better client-side validation of launch-time params
This fixes a release-blocking issue where we weren't running client-side validation until _two_ characters were entered, and we were missing pasted text.
Thanks to bmclaughlin and jrist for assistance with debugging the JavaScript on this one!
-- Matt
aeolus-devel@lists.fedorahosted.org