代码之家  ›  专栏  ›  技术社区  ›  JsWizard

在Laravel的选择框中单击鼠标如何显示模式框?

  •  1
  • JsWizard  · 技术社区  · 8 年前

    我希望在鼠标单击“Andre…”时显示模式框在列表中,选择Laravel代码中的框,如下所示。但这是行不通的。你能告诉我哪里不适合工作吗?

    “选择”框

    enter image description here

    控制器中的变量定义

    $job_types = DB::table('jobs')->pluck('job_type')
                        ->unique(function ($item){
                            return $item;
                          });;
    

    HTML(Laravel刀片)

    Job Type Field
    <div class="form-group col-sm-4" id="job_type">
        {!! Form::label('job_type', 'Type:') !!}
    
        {!! Form::select('job_type', $job_types, null, ['class' => 'form-control', 'id' => 'job_type']) !!}
    </div>
    

    模态视图

    <div class="modal fade" id="jobListModal">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span>
              </button>
              <h4 class="modal-title">Set in new job type.</h4>
            </div>
            <div class="modal-body">
              <p>New Job type:</p>
              <input type="text" id="textInput">
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              <button type="button" id="btnSave" class="btn btn-primary">Edit</button>
            </div>
          </div>
          <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
      </div>
      <!-- /.modal -->
    

    滑动分页

    $('#job_type').on('change', function (e) {
        if ('Another' == this.value) {
            $("#jobListModal").modal("show");
        }
    });
    $('#btnSave').click(function () {
        var newType = $('input#textInput').val();
        $('select#job_type option:last')
            .after('<option value="' + newType + '" selected="selected" >' + newType + '</option>');
        $('#jobListModal').modal('hide');
    });
    

    视察

    enter image description here

    3 回复  |  直到 8 年前
        1
  •  3
  •   Peerbits - Backend Team    8 年前

    尝试以下操作:如果要通过下拉文本进行匹配

    $('#job_type').on('change', function (e) {
        if ('Another' == $('#job_type option:selected').text() {
            $("#jobListModal").modal("show");
        }
    });
    
        2
  •  1
  •   Galanx    8 年前

    尝试将此代码部分更改为:

    $('#job_type').on('change', function (e) {
        if ('59' == $(this).val()) {
            $("#jobListModal").modal("show");
        }
    });
    
        3
  •  0
  •   Jigs1212    8 年前

    你试过这个吗

    $('#job_type').on('change', function (e) {
        if (59 == $(this).val()) {
            $("#jobListModal").modal("show");
        }
    });