jasny fileupload元素,无法用于编辑操作

时间:2012-11-28 17:47:48

标签: twitter-bootstrap file-upload jasny-bootstrap

我试图使用jasny-bootstrap中的fileupload进行编辑操作。有些页面用于登录,他/她已经上传了图像,我希望能够呈现它们以便用户更改或删除。

我正在使用以下

http://jasny.github.com/bootstrap/javascript.html#fileupload

以下代码段

<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>

它适用于新图像,但我如何渲染现有图像?在手册中,它说我必须使用fileupload-exists类而不是fileupload-new,我试过,它在编辑模式下显示表单。但是没有显示来自源的图像,请告知

的问候,

1 个答案:

答案 0 :(得分:4)

将图片添加为预览(因此在.fileupload-preview中)并将顶级版更改为.fileupload-exists

<div class="fileupload fileupload-exists" 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;">
     <img src="http://jasny.github.com/bootstrap/assets/img/extended-by-jasny.png">
  </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>​

同时检查这个小提琴:http://jsfiddle.net/GR2Lt/

P.S。您目前必须单击“删除”两次。这将在下一版本中修复。