1

这是警告的图像>>控制台中的Parsely警告

我像这样实例化欧芹:
$('form.parsley-survey').parsley()

警告:

“要被 Parsley 绑定,一个单选框、一个复选框和一个多选输入必须有一个名称或多个选项”

我在 parsley.js 文件中发现了这个警告:“不推荐使用 Parsley 的 pubsub 模块;在 parsley 实例或 window.Parsley 上使用 'on' 和 'off' 方法”

以下是我的一些输入:

<div class="form-container-entry-item" data-ancestor="834" data-element-type="checkboxes" data-entry="1" data-question-id="836" data-required="true">

    <input 
        id="survey_observations_attributes_2_question_id" 
        name="survey[observations_attributes][2][question_id]" 
        type="hidden" 
        value="836">

    <div class="form-group">

        <label class="col-sm-5 control-label" for="survey_observations_attributes_2_answer">checkboxlist</label>

        <div class="col-sm-7 parsley-error" style="background-color: rgb(242, 222, 222);">

          <input class="form-control" 
            data-label-value="A" id="survey_observations_attributes_2_answer_choice_ids_" 
            name="survey[observations_attributes][2][answer_choice_ids][]" 
            type="checkbox" 
            value="1122" 
            data-parsley-multiple="surveyobservations_attributes2answer_choice_ids" 
            data-parsley-id="10" 
            data-parsley-required="true">

          <label>A</label>
          <br>
          <input class="form-control" 
            data-label-value="B" id="survey_observations_attributes_2_answer_choice_ids_" 
            name="survey[observations_attributes][2][answer_choice_ids][]" 
            type="checkbox" 
            value="1123" 
            data-parsley-multiple="surveyobservations_attributes2answer_choice_ids" 
            data-parsley-required="true">

          <label>B</label>
          <br>
          <input class="form-control" 
            data-label-value="C" id="survey_observations_attributes_2_answer_choice_ids_" 
            name="survey[observations_attributes][2][answer_choice_ids][]" 
            type="checkbox" value="1124" 
            data-parsley-multiple="surveyobservations_attributes2answer_choice_ids" 
            data-parsley-required="true">

          <label>C</label>
          <br>
          <input 
            id="survey_observations_attributes_2_entry" 
            name="survey[observations_attributes][2][entry]" 
            type="hidden" 
            value="1">
        </div>

        <ul class="parsley-errors-list filled" id="parsley-id-multiple-surveyobservations_attributes2answer_choice_ids">
            <li class="parsley-required" style="margin-left: 50em;">This value is required.</li>
        </ul>

    </div>
</div>

这里有更多

<div class="form-container-entry-item" data-ancestor="834" data-element-type="multiselect" data-entry="1" data-question-id="837" data-required="true">
                  <input id="survey_observations_attributes_3_question_id" name="survey[observations_attributes][3][question_id]" type="hidden" value="837">
                  <div class="form-group">
                    <label class="col-sm-5 control-label" for="survey_observations_attributes_3_answer">chosenmultiselect</label>
                    <div class="col-sm-7">
                      <select class="chosen-multiselect form-control parsley-error" id="survey_observations_attributes_3_answer_choice_ids_" multiple="multiple" name="survey[observations_attributes][3][answer_choice_ids][]" size="10" style="display: none; background-color: rgb(242, 222, 222);" data-parsley-multiple="survey[observations_attributes][3][answer_choice_ids][]" data-parsley-id="16" data-parsley-required="true"><option value="1125">A</option>
                      <option value="1126">B</option>
                      <option value="1127">C</option></select><div class="chosen-container chosen-container-multi" style="width: 710px;" title="" id="survey_observations_attributes_3_answer_choice_ids__chosen"><ul class="chosen-choices" style="background:none; background-color:#F2DEDE;"><li class="search-field"><input type="text" value="Select Some Options" class="default parsley-success" autocomplete="off" style="width: 147px;" data-parsley-id="18" data-parsley-required="true"></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div></div>
                      <input id="survey_observations_attributes_3_entry" name="survey[observations_attributes][3][entry]" type="hidden" value="1">
                    </div><ul class="parsley-errors-list filled" id="parsley-id-multiple-survey[observations_attributes][3][answer_choice_ids][]" style="margin-left: 51em;"><li class="parsley-required">This value is required.</li></ul>
                  </div>
                </div>

我不确定为什么会出现该错误。有人可以给我一个关于发生了什么的想法吗?

4

1 回答 1

3

你有一个没有name属性的复选框吗?如果是这样,这是一个已知问题

于 2016-03-10T07:12:00.483 回答