未捕获错误:无法在ID'qq-template'找到模板脚本!

时间:2013-11-07 21:25:41

标签: fine-uploader

我刚下载了Fine Uploader 4.0的新“自定义版本”。我的页面在3.9上工作正常,几周前我安装和设置了。

我的代码:

Click "Select Files" and pick the files you would like to upload.  Then click "Upload Now" to start the transfer.
<hr>
<div id="fineuploader-s3"></div>
<div id="triggerUpload" class="btn btn-primary" style="margin-top: 10px;">
    <i class="icon-upload icon-white"></i> Upload now
</div>

    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script src="http://xxxxxxx/fineuploader-4.0.3/custom.fineuploader-4.0.3.js"></script>
    <script>


      $(document).ready(function () {

          var manualuploader;

          function check_done() {
              if (allUploadsCompleted() === true) {
                  var successUrl = "http://xxxxxxxx/FineUploadComplete?ftpSessionId=xxxxxx";
                  $.get( successUrl );
                  alert('Your upload is complete.');
                  window.top.location = "xxxxxxxx";
              } 
           }

           function allUploadsCompleted() {
               // If and only if all of Fine Uploader's uploads are in a state of completion will this function fire the provided callback.
               var inProgress = manualuploader.fineUploader('getInProgress');
               if (inProgress === 0) {
                   var failedUploads = manualuploader.fineUploader('getUploads', { status: qq.status.UPLOAD_FAILED });
                   if (failedUploads.length === 0) {
                       return true;
                   }
                }        
                return false;
            }


            manualuploader = $('#fineuploader-s3').fineUploaderS3({
                debug: true,
            autoUpload: false,
                editFilename: {
                enabled: true
            },
            element: $('#fineuploader-s3')[0],
            text: {
                uploadButton: '<i class="icon-plus icon-white"></i> Select Files'
                },
                cors: {
                       expected: true,
                       sendCredentials: true
                },
                request: {
                    endpoint: "xxxxx",
                    accessKey: "xxxx"
                },
                signature: {
                    endpoint: "http://xxxxxx/S3UploadSig"
                },
        objectProperties: {
                key:  function (fileId) { return "xxxx" + '/' + $("#fineuploader-s3").fineUploader("getName",fileId); } 
            },
                retry: {
                        showButton: true
                },
                chunking: {
                        enabled: true
                },
                resume: {
                        enabled: true
                },
                deleteFile: {
                        enabled: false
                },
                callbacks: {
                    onStatusChange: function (id, oldStatus, newStatus) {
                        // This will check to see if a file that has been cancelled
                        // would equate to all uploads being 'completed'.
                        if (newStatus === qq.status.CANCELLED) {
                            check_done();
                        }     
                    },
                    onComplete: check_done
                },
                validation: {
            allowedExtensions: [xxxxxx]
                }
          });

    $('#triggerUpload').click(function() {
            manualuploader.fineUploader('uploadStoredFiles');
        });

      });
    </script>

我在java控制台中收到以下错误......

未捕获错误:无法在ID'qq-template'找到模板脚本!

@ custom.fineuploader-4.0.3.js:4915

那么我该如何解决这个错误,是否需要对4.0进行其他更改?

谢谢, Ĵ

2 个答案:

答案 0 :(得分:3)

Fine Uploader 4.0带来了模板上的重大改进。这需要改变,因此主要版本号增加了。

简而言之,templatefileTemplate选项已移出JavaScript文件。您现在必须在文档/标记中定义模板。这具有许多优点。最大的问题是,这使得自定义Fine Uploader UI模板变得更加直观。构建提供了默认模板。您可以在styling guide中了解有关模板的更多信息,以及"Upgrading to 4.x" guide中4.0中所有其他重大更改。

请注意,fileTemplate选项已删除。默认情况下,template选项现在指向包含模板的元素。默认情况下,它希望此元素的ID为“qq-template”。您可以覆盖它并传递实际元素或不同的ID。您的模板通常包含在<script>标记中,而type为“text / template”,但这不是必需的。

答案 1 :(得分:-2)

如文档中所述,您应该在页面中使用这样的代码:

https://pastebin.com/raw/QCxYp0t3

P.S。但是,我看到一些回归(与上面的答案相反),因为我们必须手动放置那些大模板代码/块,而不是仅仅嵌入.js文件(如jQuery-UI)或其他臭名昭着的图书馆。)

至少,开发人员应该为他们保留这个功能,谁想要那个。