Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IE9错误,按钮fake用于上传图像_Javascript_Jquery_Internet Explorer_Angularjs Directive - Fatal编程技术网

Javascript IE9错误,按钮fake用于上传图像

Javascript IE9错误,按钮fake用于上传图像,javascript,jquery,internet-explorer,angularjs-directive,Javascript,Jquery,Internet Explorer,Angularjs Directive,我正在尝试修复IE9中的文件上传问题。我使用JQuery的文件上传插件,当我默认使用一个输入文件时,我没有问题,但是如果我使用一个隐藏的输入文件,并通过点击一个假按钮触发一个事件,那是行不通的 我使用两个指令来实现这一点: ecm_directives.directive('fileupload', function(){ return { restrict: 'A', scope: { done: '&', progress: '&'

我正在尝试修复IE9中的文件上传问题。我使用JQuery的文件上传插件,当我默认使用一个输入文件时,我没有问题,但是如果我使用一个隐藏的输入文件,并通过点击一个假按钮触发一个事件,那是行不通的

我使用两个指令来实现这一点:

ecm_directives.directive('fileupload', function(){
  return {
   restrict: 'A',
    scope: {
     done: '&',
     progress: '&'
   },
   link: function(scope, element, attrs) {
   var optionsObj = {
    dataType: 'json'
   };

  if (scope.done) {
    optionsObj.done = function(e, data) {
      scope.$apply(function() {
        scope.done({e: e, data: data});
        });
    };
  }

  if (scope.progress) {
    optionsObj.progress = function(e, data) {
      scope.$apply(function() {
        scope.progress({e: e, data: data});
      });
    };
  }

    //the above could easily be done in a loop, to cover
    //all API's that Fileupload provides
    element.fileupload(optionsObj);
  }
 }
});



ecm_directives.directive('uploader', function () {
  return {
    restrict: 'E',
    link: function(scope, element, attrs,ctrl) {
          element.find("button").bind("click", function(){
              element.find(":file").trigger("click").bind("change",function(){
                console.log("change");
                scope.kaka = element.find("input").val();
                scope.$apply();
                console.log("changed",  scope.kaka);
            })
          });
      }
  }
});
这是html

<div class="fake-file" ng-show="!candidateFiles.cedula.selected">
      <uploader>
        <button type="button" class="fake-input">
          <span class="placeholder ng-binding"> Seleccione un archivo de su ordenador</span>
        </button>

        <button type="button" class="btn fake-btn fake-upload-btn ng-binding">Subir</button>
        <input ng-model="ccedulaCandidato" id="cedula-file" type="file" name="ccedulaCandidato" data-url="/backend/documents/save/" class="file_upload_btn ng-isolate-scope ng-scope ng-pristine ng-valid" style="display:none" fileupload="" done="uploadFinished(e, data)">
      </uploader>
    </div>

在奥德纳多的建筑中选择
苏比尔

重点是这条线: 元素.find(“:file”).bind(“change”,function()){ }


不要在IE9中输入此代码,知道吗?

此代码在IE9中不起作用,请参阅

element.find(“:file”).trigger(“单击”)

但如果像这样添加控制台日志,您将看到按钮单击事件工作正常

element.find(“按钮”).bind(“单击”),function(){
console.log('我在);
元素.find(“:file”).trigger(“click”).bind(“change”,function(){