From 000a334f2b5a9e00e99f84be1371abf9b0738a60 Mon Sep 17 00:00:00 2001 From: Casey Holzer Date: Mon, 23 Sep 2019 15:55:35 -0600 Subject: [PATCH] allow form.reset() to work out-of-the-box (#1315) --- js/bootstrap-select.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/bootstrap-select.js b/js/bootstrap-select.js index 060772528..a1ee4a86a 100644 --- a/js/bootstrap-select.js +++ b/js/bootstrap-select.js @@ -902,7 +902,8 @@ init: function () { var that = this, - id = this.$element.attr('id'); + id = this.$element.attr('id'), + form = this.$element[0].form; selectId++; this.selectId = 'bs-select-' + selectId; @@ -1005,6 +1006,14 @@ }); } + if (form) { + $(form).on('reset' + EVENT_KEY, function () { + requestAnimationFrame(function () { + that.render(); + }); + }); + } + setTimeout(function () { that.buildList(); that.$element.trigger('loaded' + EVENT_KEY);