Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form: 'Add more' determinant function #76

Closed
jeff1evesque opened this issue Sep 1, 2014 · 4 comments · Fixed by #79
Closed

Form: 'Add more' determinant function #76

jeff1evesque opened this issue Sep 1, 2014 · 4 comments · Fixed by #79

Comments

@jeff1evesque
Copy link
Owner

We will need a function that counts the number of input fields created by the Add more button, and check whether all created field elements are defined. This function will be implemented for any fieldsets being created that depends on an input field that can be appended with additional elements. This will ensure that users provide data for all form fields, before succeeding fieldsets are available.

@jeff1evesque
Copy link
Owner Author

5914b93: We've implemented field_determinant() to Upload file, and XML file case within the Supply Dataset fieldset.

@jeff1evesque
Copy link
Owner Author

Since, html_form.js is called beforehtml_form_delegator.js, we may need to either merge the two scripts, or reload html_form.js each time html_form_delegator.js is executed.

Note: both scripts are referenced in tests/php/index.php.

Before proceeding with the above two scenarios, we will begin testing using jsfiddle, with the following code from html_form.js:

  function field_determinant(element) {
    var num_elements = element.length;

    for (var i = 0; i < num_elements; i++) {
      if(element[i].value.length < 1)
        return false;
    }

    return true;
  }

@jeff1evesque
Copy link
Owner Author

We have our jsfiddle example working properly. However, the fiddle requires the input fields to be well defined in the DOM prior to the execution of the jquery .on() method. To implement this concept into our above goal, we need to ensure all elements created by html_form.js occurs prior to the logic components of html_form_delegator.js, and within the same scope. Otherwise, the form elements created by html_form_delegator.js does not have proper scope such that we cannot enforce all form array elements to be filled before the conditional logic of html_form.js gets executed.

As mentioned above, we may need to either merge the two scripts, or reload html_form.js each time html_form_delegator.js is executed.

Note: we can implement the above jsfiddle example without the required use of the jquery .each() method.

@jeff1evesque
Copy link
Owner Author

bb54ed5: we decided to bind the .on() method to an already existing <form> element that was created prior to any javascript, specifically within tests/php/index.php.

The form behaves as intended with the exception of the following two cases:

  • Analysis Session: deleting an existing field under the Known Factors fieldset should remove the form submit button
  • Training Session: defining fields within the Classification Parameters fieldset creates the form submit button, when we add more Dependent, or Independent variables. Currently, if we do not add additional fields, then the submit button will be properly added to the DOM if the initial Dependent, and Independent fields are defined. Also, we will need to be able to remove the submit button when reselecting a choice within the Training Type fieldset, or if one of the fields within the Classification Parameters fieldset is made blank.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant