I have a button which shows a modal when clicked.
The button is:
<button type="button" class="btn btn-primary assignRole" data-toggle="modal" data-target="#assignRole">
New
</button>
and the modal is:
<div class="modal fade" id="assignRole" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Assign New Client Role to Employee</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="form-group">
</form>
<div class="modal-footer">
<button type="button" class="btn btn-warning" data-dismiss="modal">
<span class='glyphicon glyphicon-remove'></span> Close
</button>
<button type="button" class="btn btn-success add-role-to-user" data-dismiss="modal">
<span class='glyphicon glyphicon-check'></span> Add
</button>
</div>
</div>
</div>
</div>
</div>
These work fine when the button is clicked manually but I would like the modal to show on error.
I am using the following code:
error: function(errors){
setTimeout(function (){
$(".assignRole").click();
toastr.error('Validation error!', errors.responseJSON.message, {timeOut: 5000});
}, 500);
}
Could someone please point out where I am going wrong. I am using coreui admin template and chrome.