php - Bootstrap 问题, "fileupload"在模态内部不工作

标签 php javascript twitter-bootstrap

So, i am using a bootstrap modal, and inside of the modal, i want to use image upload, but when an image is selected, nothing happens, i am asuming it is a javascript issue, the script and the css is包含在标题中的模态之外。

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>
   ';
}
?>

最佳答案

尝试使用Document Ready 功能,因为Script 是在Modal HTML 之前加载的

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

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

        }); 

    });

关于php - Bootstrap 问题, "fileupload"在模态内部不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15440598/

相关文章:

PHP 如何根据字符串内容将字符串列表(数组)转换为嵌套数组

php - move_uploaded_file 失败但权限似乎正确

javascript - 规避本地文件系统上的 Chrome Access-control-allow-origin?

javascript - 选择2 "selected": true not working

javascript - 如何执行嵌套的 Javascript 函数

twitter-bootstrap - Angular 2 : How to use bootstrap-sass with @extend and mixins in Angular-CLI?

html - Bootstrap 2.3.2 移动 100% 宽度背景

php - MYSQL Select 基于 HTML 选择选项

php - shell_exec() 不执行 pdftotext 命令

twitter-bootstrap - 下拉菜单 bootstrap3 剪切移动