Skip to content

Commit

Permalink
Merge pull request #397 from kchung/master
Browse files Browse the repository at this point in the history
Prevent formatSelection for erroring when accessing an empty select input.
  • Loading branch information
ivaynberg committed Sep 10, 2012
2 parents 819cca7 + 7be0e50 commit c0ce4be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions select2.js
Expand Up @@ -926,7 +926,7 @@

if (this.opened()) return false;

event = jQuery.Event("open");
event = $.Event("open");
this.opts.element.trigger(event);
return !event.isDefaultPrevented();
},
Expand Down Expand Up @@ -1020,7 +1020,7 @@
this.results.empty();
this.clearSearch();

this.opts.element.trigger(jQuery.Event("close"));
this.opts.element.trigger($.Event("close"));
},

// abstract
Expand Down Expand Up @@ -2361,7 +2361,7 @@
return markup.join("");
},
formatSelection: function (data, container) {
return data.text;
return data ? data.text : undefined;
},
formatResultCssClass: function(data) {return undefined;},
formatNoMatches: function () { return "No matches found"; },
Expand Down

0 comments on commit c0ce4be

Please sign in to comment.