I am trying to open a modal on the change event of select Box?
This is My Modal
<!-- Modal when adding ment for upload -->
<div class="modal fade" id="fileUploadModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Comment</h4>
</div>
<div class="modal-body">
<p><textarea id = "mentsUpload"class="form-control custom-control" rows="3" style="resize:none"></textarea></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" onclick="submitXYX()" data-dismiss="modal">Submit</button>
</div>
</div>
</div>
</div>
And select Box is:
<select class="selectpicker" id = "selectNEWBox">
<option value = "1">New</option>
<option value = "2">Old</option>
<option value = "3">Scrap</option>
</select>
What I need to do is to open the Modal on change event of select Box.
What I have tried
In $(document).ready(function () {});
Approach 1
$("#selectNEWBox").change(function(){
$('#fileUploadModal').modal({
show: true
});
});
Approach 2
$("#selectNEWBox").change(function (){
$('#fileUploadModal').modal('show');
});
but these are not working.
Am I missing something?
I am trying to open a modal on the change event of select Box?
This is My Modal
<!-- Modal when adding ment for upload -->
<div class="modal fade" id="fileUploadModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add Comment</h4>
</div>
<div class="modal-body">
<p><textarea id = "mentsUpload"class="form-control custom-control" rows="3" style="resize:none"></textarea></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" onclick="submitXYX()" data-dismiss="modal">Submit</button>
</div>
</div>
</div>
</div>
And select Box is:
<select class="selectpicker" id = "selectNEWBox">
<option value = "1">New</option>
<option value = "2">Old</option>
<option value = "3">Scrap</option>
</select>
What I need to do is to open the Modal on change event of select Box.
What I have tried
In $(document).ready(function () {});
Approach 1
$("#selectNEWBox").change(function(){
$('#fileUploadModal').modal({
show: true
});
});
Approach 2
$("#selectNEWBox").change(function (){
$('#fileUploadModal').modal('show');
});
but these are not working.
Am I missing something?
Share Improve this question edited Mar 29, 2017 at 14:23 Tareque Md Hanif 873 silver badges14 bronze badges asked Mar 29, 2017 at 13:37 Geek_To_LearnGeek_To_Learn 1,9767 gold badges29 silver badges51 bronze badges 8- any error you received in console ? – RAJNIK PATEL Commented Mar 29, 2017 at 13:41
- Other than a missing semicolon at the end '.modal('show')', your code seems to be ok. Can you provide a working fiddle of the issue. – Dan Philip Bejoy Commented Mar 29, 2017 at 13:42
- works fine: codeply./go/hMooZk56uc – Carol Skelly Commented Mar 29, 2017 at 13:43
- 1 have you add bootstrap js and css library ?? – RAJNIK PATEL Commented Mar 29, 2017 at 13:45
- did you load jquery: because your code works - fiddle – birdspider Commented Mar 29, 2017 at 13:46
2 Answers
Reset to default 1just tried your code and it seem working
$( "#selectNEWBox" ).change(function() {
$('#fileUploadModal').modal('show')
});
try it here
Finally resolved the issue. It seems the issue was because of conflict of Jquery versions.
Removed the conflict and it's working now. :)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745590058a4634778.html
评论列表(0条)