[FIX] website: use dom element instead of jquery class to click input file
authorDenis Ledoux <dle@odoo.com>
Fri, 17 Oct 2014 13:29:00 +0000 (15:29 +0200)
committerDenis Ledoux <dle@odoo.com>
Fri, 17 Oct 2014 13:29:00 +0000 (15:29 +0200)
For some reasons, the browser will prevent to open the system file browser when clicking the input file with javascript using the jquery class element, but it works when using the standard js dom element.

addons/website/static/src/js/website.editor.js

index 2764e21..a339ea6 100644 (file)
                 this.changed($(e.target));
             },
             'click button.filepicker': function () {
-                this.$('input[type=file]').click();
+                var filepicker = this.$('input[type=file]');
+                if (!_.isEmpty(filepicker)){
+                    filepicker[0].click();
+                }
             },
             'click .js_disable_optimization': function () {
                 this.$('input[name="disable_optimization"]').val('1');
-                this.$('button.filepicker').click();
+                var filepicker = this.$('button.filepicker');
+                if (!_.isEmpty(filepicker)){
+                    filepicker[0].click();
+                }
             },
             'change input[type=file]': 'file_selection',
             'submit form': 'form_submit',