Skip to content

Commit

Permalink
Properly unbind events on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
rvera committed Jan 25, 2014
1 parent d7ab1a7 commit 69078cc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.3
0.2.4
13 changes: 12 additions & 1 deletion image-picker/image-picker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Image Picker
// by Rodrigo Vera
//
// Version 0.2.3
// Version 0.2.4
// Full source at https://github.com/rvera/image-picker
// MIT License, https://github.com/rvera/image-picker/blob/master/LICENSE
// Generated by CoffeeScript 1.4.0
Expand Down Expand Up @@ -63,7 +63,14 @@
}

ImagePicker.prototype.destroy = function() {
var option, _i, _len, _ref;
_ref = this.picker_options;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
option.destroy();
}
this.picker.remove();
this.select.unbind("change");
this.select.removeData("picker");
return this.select.show();
};
Expand Down Expand Up @@ -212,6 +219,10 @@
this.create_node();
}

ImagePickerOption.prototype.destroy = function() {
return this.node.find(".thumbnail").unbind();
};

ImagePickerOption.prototype.has_image = function() {
return this.option.data("img-src") != null;
};
Expand Down
4 changes: 2 additions & 2 deletions image-picker/image-picker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions source/coffee/image-picker.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class ImagePicker
@build_and_append_picker()

destroy: ->
for option in @picker_options
option.destroy()
@picker.remove()
@select.unbind("change")
@select.removeData "picker"
@select.show()

Expand Down Expand Up @@ -114,6 +117,9 @@ class ImagePickerOption
@option = jQuery(option_element)
@create_node()

destroy: ->
@node.find(".thumbnail").unbind()

has_image: () ->
@option.data("img-src")?

Expand Down

0 comments on commit 69078cc

Please sign in to comment.