Jquery 无论如何,这种方法应该是有效的,但它没有。所以我在网上查了一下,它需要一个事件监听器。你能提供一个只包含html的JSFIDLE吗?这里是,但这里两个数据都没有传递。。。在我的页面中,输入的文本确实有数据……我刚刚检查了Chrome的开发者控制台,有一个错
Jquery 无论如何,这种方法应该是有效的,但它没有。所以我在网上查了一下,它需要一个事件监听器。你能提供一个只包含html的JSFIDLE吗?这里是,但这里两个数据都没有传递。。。在我的页面中,输入的文本确实有数据……我刚刚检查了Chrome的开发者控制台,有一个错,jquery,twitter-bootstrap,bootstrap-select,Jquery,Twitter Bootstrap,Bootstrap Select,无论如何,这种方法应该是有效的,但它没有。所以我在网上查了一下,它需要一个事件监听器。你能提供一个只包含html的JSFIDLE吗?这里是,但这里两个数据都没有传递。。。在我的页面中,输入的文本确实有数据……我刚刚检查了Chrome的开发者控制台,有一个错误声明:uncaughttypeerror:$(…).find(…).selectpicker不是一个函数。因此,我得到了一个需要首先解决的问题……您需要将您的js代码包装在jquery的dom就绪回调函数中:jquery(document).
无论如何,这种方法应该是有效的,但它没有。所以我在网上查了一下,它需要一个事件监听器。你能提供一个只包含html的JSFIDLE吗?这里是,但这里两个数据都没有传递。。。在我的页面中,输入的文本确实有数据……我刚刚检查了Chrome的开发者控制台,有一个错误声明:
uncaughttypeerror:$(…).find(…).selectpicker不是一个函数
。因此,我得到了一个需要首先解决的问题……您需要将您的js代码包装在jquery的dom就绪回调函数中:jquery(document).ready(function(){//您的代码应该在这里..})
如果我删除您注释的代码,按钮将不会打开模式。我不知道为什么,但我认为你的方法应该是有效的,但它没有。所以我在网上查了一下,它需要一个事件监听器。你能提供一个只包含html的JSFIDLE吗?这里是,但这里两个数据都没有传递。。。在我的页面中,输入的文本确实有数据……我刚刚检查了Chrome的开发者控制台,有一个错误声明:uncaughttypeerror:$(…).find(…).selectpicker不是一个函数
。因此,我得到了一个需要首先解决的问题……您需要将js代码封装在jquery的dom就绪回调函数中:jquery(document).ready(function(){//您的代码应该在这里..})
@foreach ($cklist as $key=>$cklst)
@if (strtoupper($sort->sectionFK)==strtoupper($cklst->schSectionFK))
<?php $index++; ?>
<tr>
<!-- Task Name -->
<td class="table-text" width="10px">
<div>{{$index }}</div>
</td>
<td class="table-text">
<div>{{strtoupper($cklst->clQuestion)}}</div>
</td>
<td>
<!----- Edit Question Item Button ----->
<button type="button" data-toggle="modal" data-target=".qs-item-modal-lg" data-question="{{$cklst->clQuestion}}" data-question-id="{{$cklst->cklistPK}}" data-question-severity-id="{{$cklst->severityFK}}" @foreach ($svrity as $key=>$slct2)
@if ($slct2->severityPK == $cklst->severityFK)
data-question-severity-txt="{{$slct2->severityName}}"
@endif
@endforeach
class="btn btn-warning">Edit</button>
</td>
<td align="center" width="10px">
<form action="{{ url('addref/'.$cklst->cklistPK) }}" method="POST">
{{ csrf_field() }}
<input type="hidden" name="schemeID" value="{{$id}}">
<input type="hidden" name="cklistID" value="{{$cklst->cklistPK}}">
<button class="btn btn-info" type="submit">Get Reference</button>
</form>
</td>
<td align="center" width="10px">
<form action="{{ url('delcheck/'.$cklst->cklistPK) }}" method="POST" class="delete">
{{ csrf_field() }}
{{ method_field('DELETE') }}
<button class="btn btn-danger" type="submit">Delete</button>
</form>
</td>
</tr>
@endif
@endforeach
<!----- Edit Question Item Modal ----->
<div class="modal fade qs-item-modal-lg" id="editqstn" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myLargeModalLabel">Edit Question Item</h4>
</div>
<form action="{{url('editquestion')}}" method="POST">
{{ csrf_field() }}
{{ method_field('PUT') }}
<div class="modal-body">
<div class="row">
<div class="col-sm-12">
<div class="text-left">
<div class="col-sm-8">
<h4>
<label>Question Name</label>
<input type="text" class="form-control" name="selectedquestion" value="">
<input type="hidden" name="selectedquestionID" value="">
</h4>
</div>
<div class="col-sm-4">
<h4>
<label>Severity</label>
<select class="selectpicker form-control" id="svrty" name="selectedquestionSvrty">
<option selected value=""></option>
@foreach ($svrity as $key=>$slct2)
<option value="{{$slct2->severityPK}}">{{strtoupper($slct2->severityName)}}</option>
@endforeach
</select>
</h4>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
$("#editqstn").on("show.bs.modal", function (e) {
//get data-question attributes of the clicked element
var slctqstn = $(e.relatedTarget).data('question');
var slctqstnid = $(e.relatedTarget).data('question-id');
var slctqstnsvrty = $(e.relatedTarget).data('question-severity');
var slctqstnsvrtytxt = $(e.relatedTarget).data('question-severity-txt');
//populate the input
$(e.currentTarget).find('input[name="selectedquestion"]').val(slctqstn);
$(e.currentTarget).find('input[name="selectedquestionID"]').val(slctqstnid);
$('.selectpicker').on('change', function(e){
//populate the bootstrap-select selected value
$(e.currentTarget).find('#svrty').selectpicker('val', slctqstnsvrty);
//populate the bootstrap-select selected string text
$(e.currentTarget).find('#svrty').text(slctqstnsvrtytxt).selectpicker('render');
});
});
$("#editqstn").on("show.bs.modal", function (e) {
//get data-question attributes of the clicked element
var slctqstn = $(e.relatedTarget).data('question');
var slctqstnid = $(e.relatedTarget).data('question-id');
var slctqstnsvrty = $(e.relatedTarget).data('question-severity');
var slctqstnsvrtytxt = $(e.relatedTarget).data('question-severity-txt');
//populate the input
$(e.currentTarget).find('input[name="selectedquestion"]').val(slctqstn);
$(e.currentTarget).find('input[name="selectedquestionID"]').val(slctqstnid);
// Yu don't need this part
/*
$('.selectpicker').on('change', function(e){
//populate the bootstrap-select selected value
$(e.currentTarget).find('#svrty').selectpicker('val', slctqstnsvrty);
//populate the bootstrap-select selected string text
$(e.currentTarget).find('#svrty').text(slctqstnsvrtytxt).selectpicker('render');
});
*/
// Instead you can use the following-
$(e.currentTarget).find('#svrty').val(slctqstnsvrty).selectpicker('refresh');
});