在Laravel的select框中点击鼠标如何显示模态框?

How modal box show by mouse click in select box at the Laravel?

我希望在 Laravel 代码中的列表 select 框中鼠标单击 "Andre..." 时显示模态框,如下所示。但这不起作用。你能告诉我在哪里工作不正确吗?

Select盒子

控制器中的变量定义

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

HTML(Laravel Blade)

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 -->

Jquery

$('#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');
});

检验

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

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

试试这个:如果你想通过下拉文本匹配

$('#job_type').on('change', function (e) {
    if ('Another' == $('#job_type option:selected').text() {
        $("#jobListModal").modal("show");
    }
});

你试过这个吗

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