srs81 / CakePHP-AjaxMultiUpload

CakePHP 2 plugin to allow for easy multi-file upload with AJAX
Other
65 stars 33 forks source link

IE9 bug #19

Closed ithuriel22 closed 11 years ago

ithuriel22 commented 12 years ago

Hi!

I saw, that someone posted an issue with IE9 compability. He had trouble with the upload button and i have the same problem with it, but i already know what causes it. The problem is with this part of the UploadHelper (edit funciton) ->

function createUploader(){ var amuCollection = document.getElementsByName('AjaxMultiUpload'); for (var i = 0, max = amuCollection.length; i < max; i++) { action = amuCollection[i].id.replace('AjaxMultiUpload', ''); window['uploader'+i] = new qq.FileUploader({ element: amuCollection[i], action: '".$webroot."/uploads/upload/' + action + '/', debug: true }); } } This creates the upload button, but in IE you can't get the elemenets by their names, only if the elements are form elements. The amuCollection variable will be empty. It doesn't work with div except if the id and name are the same. It's really annoying.

ithuriel22 commented 12 years ago

Fix: ...div id='AjaxMultiUpload$lastDir' class='AjaxMultiUpload'> noscript>

Please enable JavaScript to use file uploader.

            /noscript>
        /div>
        script src='".$webroot."/js/fileuploader.js' type='text/javascript'>/script>
        script>
            function createUploader(){
                var amuCollection = $('.AjaxMultiUpload');
                for (var i = 0, max = amuCollection.length; i < max; i++) {...

I removed the name tag from the div and added as class then i used jquery at the amuCollecton and tadaaaaa it works in IE9! :D

srs81 commented 12 years ago

Thanks! Can you issue a pull request and I'll merge the code after checking? Really appreciate this fix.

srs81 commented 11 years ago

Hey this looks good, I just realized it only works if you have jQuery though. Do you have a solution without jQuery?

srs81 commented 11 years ago

Replaced getElementsByName() with getElementById() - please let me know if there's still an issue.