Bootstrap 问题,“fileuload”在模态内部不起作用

ylamdve6  于 2023-01-22  发布在  Bootstrap
关注(0)|答案(3)|浏览(140)

所以,我使用了一个引导模式,在模式内部,我想使用图像上传,但是当选择一个图像时,什么也没有发生,我认为这是一个javascript问题,脚本和css包含在头中的模式外部。
http://jasny.github.com/bootstrap/javascript.html#fileupload
有什么建议吗?我想这是javascript的问题

<?php 
if (isset($_SESSION['login']) and !empty($_SESSION['login']) and $_SESSION['rank'] == 3) {

echo '
    <!-- Modal -->
    <div id="insert_post_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
       <div class="modal-header">
       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
       <h3 id="myModalLabel">Insert Post</h3>
      </div>
      <div class="modal-body">
      <p>

    <form action="insert_post_sql" method="post" enctype="multipart/form-data">

        <table border="0">

<div class="fileupload fileupload-new" data-provides="fileupload">
    <div class="fileupload-new thumbnail" style="width: 200px; height: 150px;"><img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image" />
    </div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;">
    </div>
<div>
    <span class="btn btn-file"><span class="fileupload-new">Select image</span>
        <span class="fileupload-exists">Change</span><input type="file" /></span>
        <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
</div>
</div>
          </table>
     </form>

     </p>
     </div>
     <div class="modal-footer">
     <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
     <input type="submit" button class="btn btn-primary" value="Submit Post">
     </div>
   </div>
   </form>
   ';
}
?>
d8tt03nd

d8tt03nd1#

尝试使用文档就绪功能,因为脚本在模态HTML之前加载

$('document').ready(function(){
        $('#insert_post_modal').on('shown', function(){

           $('.fileupload').fileupload();

        }); 

    });
dba5bblo

dba5bblo2#

尝试在所示模态上调用文件加载(即当用户打开它时):

$('#insert_post_modal').on('shown', function(){

   $('.fileupload').fileupload();

});

抱歉,现在无法测试

kwvwclae

kwvwclae3#

$(文档).就绪(函数(){ $图像裁剪= $('#图像演示').裁剪({启用Exif:真,视口:{宽:300,高:300,类型:“正方形”//圆形},边界:{宽:400,高:400 } });

相关问题