From f726193117c394635936d661c594a3d69fdb6356 Mon Sep 17 00:00:00 2001 From: David Pereira Date: Tue, 26 Apr 2016 17:01:12 +0100 Subject: [PATCH] selected default selected value I added this to enable default binding by reading the val from the selected index value. (For instance, when knocnkout.js does the binding to a selected it doens't add an option attribute, it sets the select.options[select.selectedIndex] value. --- jquery.minimalect.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/jquery.minimalect.js b/jquery.minimalect.js index f4c3409..b63dfc8 100644 --- a/jquery.minimalect.js +++ b/jquery.minimalect.js @@ -92,13 +92,18 @@ if(this.element.prop("disabled")) this.wrapper.addClass(op.class_disabled); - // create and add the input - this.input = $( - ''+ - (this.element.find("option[selected]").html() || "")+ + ' data-placeholder="' + data_placeholder + + '" ' + (this.element.is('[tabindex]') ? ('tabindex=' + this.element.attr('tabindex')) : '') + '>' + + (data_placeholder_html || "") + '' ).appendTo(this.wrapper);