Knockout.js Uploadify说它可以';当我将DOM对象直接传递给占位符元素时,它找不到占位符元素,但Uploadifive可以工作,为什么?

Knockout.js Uploadify说它可以';当我将DOM对象直接传递给占位符元素时,它找不到占位符元素,但Uploadifive可以工作,为什么?,knockout.js,uploadify,Knockout.js,Uploadify,我试图将uploadify/uploadifive与knockout一起使用,但一直出现无法找到placeholder元素的错误。该错误仅在运行使用uploadify(flash)版本的IE时发生。其他浏览器很好,因为它们使用的是uploadifive(html5)。为什么它在IE中不起作用 HTML 问题在于没有在输入元素上添加id,并且需要将uploadify创建代码包装到超时函数中。问题中的代码反映了将调用$.uploadify包装起来的超时。这是因为uploadify在内部使用swfup

我试图将uploadify/uploadifive与knockout一起使用,但一直出现无法找到placeholder元素的错误。该错误仅在运行使用uploadify(flash)版本的IE时发生。其他浏览器很好,因为它们使用的是uploadifive(html5)。为什么它在IE中不起作用

HTML


问题在于没有在输入元素上添加id,并且需要将uploadify创建代码包装到超时函数中。问题中的代码反映了将调用$.uploadify包装起来的超时。这是因为uploadify在内部使用swfupload,它将尝试按id查询输入元素。如果不想在输入元素上添加id属性,还可以向uploadify脚本添加一点代码,该脚本将生成一个id

这是我补充的

        //Add id to DOM object if it doesn't exist. 
        if (!$this.attr('id')) {
            $this.attr('id', 'uploadify' + uploadControlIdCounter);
            uploadControlIdCounter += 1;
        }
同样的事情,周围有更多的上下文

    /*
   Uploadify v3.1.1
   Copyright (c) 2012 Reactive Apps, Ronnie Garcia
   Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
   */

   (function($) {
   var uploadControlIdCounter = 0;
   // These methods can be called by adding them as the first argument in the uploadify plugin call
var methods = {

    init : function(options, swfUploadOptions) {

        return this.each(function() {

            // Create a reference to the jQuery DOM object
            var $this = $(this);

            //Add id to DOM object if it doesn't exist. 
            if (!$this.attr('id')) {
                $this.attr('id', 'uploadify' + uploadControlIdCounter);
                uploadControlIdCounter += 1;
            }
/*
上传v3.1.1
版权所有(c)2012反应式应用程序,Ronnie Garcia
根据麻省理工学院许可证发布
*/
(函数($){
var uploadControlIdCounter=0;
//可以通过将这些方法添加为uploadify插件调用的第一个参数来调用它们
var方法={
初始化:函数(选项、SWFUPLO采用){
返回此值。每个(函数(){
//创建对jQuery DOM对象的引用
var$this=$(this);
//如果DOM对象不存在,则向其添加id。
if(!$this.attr('id')){
$this.attr('id','uploadify'+uploadControlIdCounter);
uploadControlIdCounter+=1;
}

我想添加id属性的代码也可以移动到bindingHandler,而不是编辑uploadify文件
        //Add id to DOM object if it doesn't exist. 
        if (!$this.attr('id')) {
            $this.attr('id', 'uploadify' + uploadControlIdCounter);
            uploadControlIdCounter += 1;
        }
    /*
   Uploadify v3.1.1
   Copyright (c) 2012 Reactive Apps, Ronnie Garcia
   Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
   */

   (function($) {
   var uploadControlIdCounter = 0;
   // These methods can be called by adding them as the first argument in the uploadify plugin call
var methods = {

    init : function(options, swfUploadOptions) {

        return this.each(function() {

            // Create a reference to the jQuery DOM object
            var $this = $(this);

            //Add id to DOM object if it doesn't exist. 
            if (!$this.attr('id')) {
                $this.attr('id', 'uploadify' + uploadControlIdCounter);
                uploadControlIdCounter += 1;
            }