Skip to content

Commit

Permalink
call setValue() only once
Browse files Browse the repository at this point in the history
otherwise every time an Ajax response is returned (e.g. during searching), the value is set to data.value
  • Loading branch information
yihui committed Sep 9, 2015
1 parent 5a022b0 commit 076ac26
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions srcjs/input_binding_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ $.extend(selectInputBinding, {
if (data.hasOwnProperty('url')) {
selectize = this._selectize(el);
selectize.clearOptions();
var thiz = this;
var thiz = this, loaded = false;
selectize.settings.load = function(query, callback) {
var settings = selectize.settings;
$.ajax({
Expand All @@ -72,8 +72,9 @@ $.extend(selectInputBinding, {
},
success: function(res) {
callback(res);
if (data.hasOwnProperty('value'))
if (!loaded && data.hasOwnProperty('value'))
thiz.setValue(el, data.value);
loaded = true;
}
});
};
Expand Down

0 comments on commit 076ac26

Please sign in to comment.