Javascript dos不能在bootstrap模式中工作

时间:2017-08-19 19:14:44

标签: javascript jquery html twitter-bootstrap

我一直在与有趣的错误作斗争。我的Javascript代码在bootstrap模式中不起作用。

我正在使用"Dropzone.js"文件上传系统。 问题是:它加载dropzone.js,但不会加载我的自定义js,更改dropzone.js输入字段位于许多模态之一。

我试过,如果我将输入字段放在任何其他不是模态的地方,它会加载我的自定义脚本,但是当它处于模态时,它不会加载。

添加脚本:

<link href="../Style/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="../Style/vendors/dropzone/dist/min/dropzone.min.css" rel="stylesheet">

<script src="../Style/vendors/pnotify/dist/pnotify.nonblock.js"></script>
<script src="../Style/vendors/dropzone/dist/min/dropzone.min.js"></script>

<script>
    $('#image_upload_panel').on('shown', function() {
    Dropzone.options.uploadWidget = {
    autoProcessQueue: false,
    maxFilesize: 10,
    maxFiles: 1,
    addRemoveLinks: true,
    dictResponseError: 'Server not Configured',
    acceptedFiles: ".png,.jpg,.gif,.bmp,.jpeg",
    init:function(){
      var self = this;
      // config
      self.options.addRemoveLinks = true;
      self.options.dictRemoveFile = "Delete";
      //New file added
      self.on("addedfile", function (file) {
        console.log('new file added ', file);
      });
      // Send file starts
      self.on("sending", function (file) {
        console.log('upload started', file);
        $('.meter').show();
      });

      // File upload Progress
      self.on("totaluploadprogress", function (progress) {
        console.log("progress ", progress);
        $('.roller').width(progress + '%');
      });

      self.on("queuecomplete", function (progress) {
        $('.meter').delay(999).slideUp(999);
      });

      // On removing file
      self.on("removedfile", function (file) {
        console.log(file);
      });
    }
    };
  });
</script>

打开模态的按钮:

<a id="post_upload" class="post_upload" style="float:right; margin-top:-20px;" href="#" data-toggle="modal" data-target=".image_upload"><button type="submit" name="btn-upload" id="btn-upload" class="btn btn-danger ">Upload Image</button></a>

模态:

<!-- Image Upload -->
<div class="modal fade image_upload" id="image_upload_panel" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form class="dropzone" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="uploadWidget">
                <b><center><div class="modal-header">Upload Post</div></center></b>
                <center><input type="text" name="title" style="margin-top:20px; width:60%; height:35px; text-align:center;" placeholder="Here goes title!" /></center>
                <hr>
                <div class="dz-message" data-dz-message><span>Drop or select your file!</span></div>
                <div class="modal-footer"><button type="submit" id="uploadPostForm" name="uploadPostForm" class="btn btn-primary ">Upload</button></div>
            </form>
        </div>
    </div>
</div>
<!-- END OF Image Upload -->

1 个答案:

答案 0 :(得分:0)

我无法等待您回答我的问题,询问这是 bootstrap 4 。我必须在几分钟后离开,我希望这能解决你的问题。如果没有,请告诉我,我会看到我能做些什么。请参阅代码中的注释,但我得到了这个工作,并且正在应用本地配置:

org.eclipse.persistence.exceptions.JPQLException
Exception Description: Problem compiling [SELECT u FROM User]. 
The abstract schema type 'User' is unknown.