Matheus Miranda Matheus Miranda -4 years ago 136
Javascript Question

Event type of calling 2 times

Please check my code:


<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Teste</button>

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Teste modal</h4>
<div class="modal-body">
<label class="control-label">Select File</label>
<input id="input-1a" type="file" class="file" data-show-preview="false">
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>



$('#myModal').on('', function(e) {

I'm using this plugin:

Here it is in jsfiddle:

In line
$('#myModal').on('', function(e)
, it does 2 times.

Removing line
<input id="input-1a" type="file" class="file" data-show-preview="false">
, works correctly.

Any solution ?

Answer Source

You are using two JavaScript libraries that can run into conflicts with jQuery. In order to avoid these conflicts, you need to put jQuery in no-conflict mode as following:

jQuery(document).ready(function( $ ) {
    $('#myModal').on('', function(e) {

Hope this help!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download