From 08f688ae9d033fc23c392f6fdb25b687aa952fbe 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 2a879b27c..3f2df3aef 100644 --- a/js/bootstrap-select.js +++ b/js/bootstrap-select.js @@ -913,7 +913,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; @@ -1016,6 +1017,14 @@ }); } + if (form) { + $(form).on('reset' + EVENT_KEY, function () { + requestAnimationFrame(function () { + that.render(); + }); + }); + } + setTimeout(function () { that.buildList(); that.$element.trigger('loaded' + EVENT_KEY);