我在Laravel-5.8中有这样的代码:
<button type="button" class="btn btn-xs btn-warning" data-toggle="modal" data-target="#comment_emp{{ $goal->id }}" data-original-title="Comment">
<i class="fas text-white">Add Comment</i>
</button>上面的按钮生成如下所示的模态表单:
<div class="modal fade" id="comment_emp{{ $goal->id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="{{route('appraisal.appraisal_year_end_setups.employee_year_end_comment',['id'=>$goal->id])}}" method="post" enctype="multipart/form-data" id="review_comment-form">
{{ csrf_field() }}
<div class="modal-header">
Self-Review Comment
</div>
<div class="col-md-12">
<div class="form-group">
<label class="control-label"> Rating:<span style="color:red;">*</span></label>
<input type="hidden" id="myRatingLimit" value="{{ $goal->goaltype->ratingLimit ? $goal->goaltype->ratingLimit->max_rating : '' }}">
<input type="hidden" id="myWeightedScore" value="{{$goal->weighted_score ?? '' }}">
<input type="text" id="myRating" name="employee_year_end_weighted_score" class="form-control myRating" onkeyup="checkScore(this.value)" required>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success btn-ok">Save</button>
</div>
</form>
</div>
</div>
</div>
如何传递这些数据(myRatingLimit和myWeightedScore):
<input type="hidden" id="myRatingLimit" value="{{ $goal->goaltype->ratingLimit ? $goal->goaltype->ratingLimit->max_rating : '' }}">
<input type="hidden" id="myWeightedScore" value="{{$goal->weighted_score ?? '' }}">进入:
< script type = "text/javascript" >
$(document).ready(function() {
$('#comment_emp{{ $goal->id }}').on('show.bs.modal', function(event) {
});
}); <
/script>
发布于 2020-11-18 17:43:56
不干这个吗?
$('#MODAL_id or .ModalClass').on('show.bs.modal', function(event) {
$("#myRatingLimit").val();
$("#myWeightedScore").val();
});https://stackoverflow.com/questions/64890107
复制相似问题