Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Exclude Bug with Fix #28

Open
arkytn opened this issue Jul 4, 2019 · 0 comments
Open

Exclude Bug with Fix #28

arkytn opened this issue Jul 4, 2019 · 0 comments

Comments

@arkytn
Copy link
Contributor

arkytn commented Jul 4, 2019

An old bug has reappeared in v1.4.5. When you exclude fields from saving, it also removes them from the actual form. Your previous fix method of changing getFormData() to use $.extend() doesn't work now, at least in Chrome. The extend is doing a shallow copy so all the fields are by reference. Change the workingObject and theform changes as well. Even adding extend(true,{}, theform); didn't help.

I've rewritten it so it no longer needs cloning at all. Simpler filtering routine. Removes items from the save list without affecting the original form.

    /*
    * Serialize the form data, omit excluded fields marked with data-sayt-exclude attribute.
    */
    function getFormData(theform, excludeSelectors) {
      // almost all useable clone methods pass by reference
      // so I went to a filter style fix on the DOM elements.

      excludeSelectors.push('[data-sayt-exclude]'); // Add attribute selector to the list
      $elements = theform.find(':input[name]'); //All fields with names
      $elements = $elements.not(excludeSelectors.join()); //multi select
      var form_data = $elements.serializeArray();
      return form_data;
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant