Browse Source

Fix #96, Fix #97: Reset events correctly with plugin refresh method

Kartik Visweswaran 10 years ago
parent
commit
8a6853b736
3 changed files with 9 additions and 7 deletions
  1. 1 0
      CHANGE.md
  2. 8 7
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -10,6 +10,7 @@ version 4.1.4
 6. (enh #93): Better styling of file upload icon indicators in thumbnails.
 6. (enh #93): Better styling of file upload icon indicators in thumbnails.
 7. Code cleanup with reusable methods for event raising and outData generation.
 7. Code cleanup with reusable methods for event raising and outData generation.
 8. (bug #95): Correct event off for drag & drop in plugin refresh method.
 8. (bug #95): Correct event off for drag & drop in plugin refresh method.
+8. (bug #97): Reset events correctly with plugin refresh method.
 
 
 version 4.1.3
 version 4.1.3
 =============
 =============

+ 8 - 7
js/fileinput.js

@@ -344,28 +344,29 @@
         listen: function () {
         listen: function () {
             var self = this, $el = self.$element, $cap = self.$captionContainer, $btnFile = self.$btnFile;
             var self = this, $el = self.$element, $cap = self.$captionContainer, $btnFile = self.$btnFile;
             $el.on('change', $.proxy(self.change, self));
             $el.on('change', $.proxy(self.change, self));
-            $(window).on('resize', function() {
+            $(window).off('resize').on('resize', function() {
                 setTimeout(function() {
                 setTimeout(function() {
                     self.autoSizeCaption();
                     self.autoSizeCaption();
                 }, 50);  
                 }, 50);  
             });
             });
-            $btnFile.on('click', function (ev) {
+            $btnFile.off('click').on('click', function (ev) {
                 self.raise('filebrowse');
                 self.raise('filebrowse');
                 if (self.isError && !self.isUploadable) {
                 if (self.isError && !self.isUploadable) {
                     self.clear(false);
                     self.clear(false);
                 }
                 }
                 $cap.focus();
                 $cap.focus();
             });
             });
-            $el.closest('form').on('reset', $.proxy(self.reset, self));
-            self.$container.on('click', '.fileinput-remove:not([disabled])', $.proxy(self.clear, self));
-            self.$container.on('click', '.fileinput-cancel', $.proxy(self.cancel, self));
+            $el.closest('form').off('reset').on('reset', $.proxy(self.reset, self));
+            self.$container.off('click')
+                .on('click', '.fileinput-remove:not([disabled])', $.proxy(self.clear, self))
+                .on('click', '.fileinput-cancel', $.proxy(self.cancel, self));
             if (self.isUploadable && self.dropZoneEnabled && self.showPreview) {
             if (self.isUploadable && self.dropZoneEnabled && self.showPreview) {
                 self.initDragDrop();
                 self.initDragDrop();
             }
             }
             if (!self.isUploadable) {
             if (!self.isUploadable) {
                 return;
                 return;
             }
             }
-            self.$container.find('.kv-fileinput-upload').on('click', function(e) {
+            self.$container.find('.kv-fileinput-upload').off('click').on('click', function(e) {
                 if (!self.isUploadable) {
                 if (!self.isUploadable) {
                     return;
                     return;
                 }
                 }
@@ -436,9 +437,9 @@
             $el.off();
             $el.off();
             self.init(params);
             self.init(params);
             var $zone = self.$container.find('.file-drop-zone');
             var $zone = self.$container.find('.file-drop-zone');
-            $el.on('change', $.proxy(self.change, self));
             $zone.off('dragenter dragover drop');
             $zone.off('dragenter dragover drop');
             $(document).off('dragenter dragover drop');
             $(document).off('dragenter dragover drop');
+            self.listen();
             self.setFileDropZoneTitle();
             self.setFileDropZoneTitle();
         },
         },
         initDragDrop: function() {
         initDragDrop: function() {

File diff suppressed because it is too large
+ 0 - 0
js/fileinput.min.js


Some files were not shown because too many files changed in this diff