简体   繁体   English

单击Krajee文件输入上的按钮后更改预览图像

[英]Change preview Image after clicking a button on krajee file input

I have many records in a table in my page, each of them has an "edit" button, it gets all the data in relation of that record from server, and then it fills the form next to the table. 我的页面中的一个表中有很多记录,每个记录都有一个“编辑”按钮,它从服务器获取与该记录相关的所有数据,然后填充表旁边的表单。

Thing is, Im using Krajee File Input, and I can't seem to change the preview image to the one I previously uploaded in server. 事情是,我正在使用Krajee File Input,而我似乎无法将预览图像更改为以前在服务器中上传的图像。 When I click "Edit", It should change the preview image everytime an edit button of any record is clicked, and show the image of that record in the File Input Plug-in. 当我单击“编辑”时,每次单击任何记录的编辑按钮时,它都应更改预览图像,并在文件输入插件中显示该记录的图像。

First question: Is that even possible? 第一个问题:那有可能吗?

Second and last, I leave my JS code, initialisation: 最后,我留下我的JS代码,初始化:

$(document).on('ready', function() 
{
  $('#photo').fileinput(
                      {
                       overwriteInitial: true,
                       maxFileSize: 100,
                       showRemove:false
                       }                           
                       );    
 });

The Edit function that inside has the FileInput code part. 里面的Edit函数具有FileInput代码部分。

$("#photo").fileinput('refresh', 
                         {
                             initailPreview:
                             [
                                 '<img src="../img/Legacy.jpg" class="file-preview-image">'
                             ],
                             showUpload:false 
                         }
                         );

For what I have seen so far, It refreshes the Plug-in, it removes the "Upload" button, but the image doesn't show. 对于我到目前为止所看到的,它刷新了插件,它删除了“上传”按钮,但是图像没有显示。 The images only appear when I add them in the "OnReady". 这些图像仅在将它们添加到“ OnReady”中时出现。 And for practicall matters I just used any image stored in my project (Legacy.jpg), to see if it works. 对于实际事务,我只使用了存储在项目(Legacy.jpg)中的任何图像,以查看其是否有效。

哦,天哪,它是“初始”而不是“初始”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM