$("#report-issue-modal-window").html("<%= escape_javascript(render partial: 'report_issue_popup') %>");
$("#report-issue-modal-window .modal").modal('show');
-// Disable the submit button until the problem description is entered
+// Disable the submit button on modal loading
$submit = $('#report-issue-submit');
-
-var problem_desc = document.forms["report-issue-form"]["report_issue_text"].value;
-if (problem_desc == null || problem_desc == "") {
- $submit.attr('disabled', true);
-}
+$submit.attr('disabled', true);
// capture events to enable submit button when applicable
$('#report_issue_text').bind('input propertychange', function() {
var problem_desc = document.forms["report-issue-form"]["report_issue_text"].value;
-
- var trigger = false;
- if (problem_desc == null || problem_desc == "") {
- trigger = true;
+ if (problem_desc === null || problem_desc === "") {
+ $submit.attr('disabled', true)
+ } else {
+ $submit.removeAttr('disabled');
}
- trigger ? $submit.attr('disabled', true) : $submit.removeAttr('disabled');
});
# enter a report text and click on report
page.find_field('report_issue_text').set 'my test report text'
- assert page.has_button?('Send problem report'), 'Send problem report button not enabled after entering text'
+ assert page.has_button?('Send problem report'), 'Send problem report button not enabled after entering text'
click_button 'Send problem report'
# ajax success updated button texts and added footer message