Disabled fields not picked up by serializeArray

前端 未结 4 952
伪装坚强ぢ
伪装坚强ぢ 2020-12-17 09:20

(Question updated to reflect real issue)

I just realized that serializeArray is not fetching content from disabled fields.

A set of

4条回答
  •  离开以前
    2020-12-17 09:37

    This is expected behavior and won't be fixed. Here is a workaround

    function serializeJSONIncludingDisabledFields (form) {
      var fields = form.find('[disabled]');
      fields.prop('disabled', false);
      var json = form.serializeJSON();
      fields.prop('disabled', true);
      return json;
    }
    

    Link to the issue

提交回复
热议问题