From b227a5e2b4327547f7c9abe0c1d7fcf402dc7b43 Mon Sep 17 00:00:00 2001
From: Chris Trinh <ChrisT11@verifone.com>
Date: Thu, 12 May 2016 13:38:36 -0700
Subject: [PATCH 1/2] Fix bug causing onselected to be fired twice and fix
 formmatting

---
 jquery.dropdown.js | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/jquery.dropdown.js b/jquery.dropdown.js
index d3fd63d..8f1327d 100644
--- a/jquery.dropdown.js
+++ b/jquery.dropdown.js
@@ -80,9 +80,6 @@
           $dynamicInput.find("input").attr("placeholder", options.dynamicOptLabel);
           $ul.append($dynamicInput);
         }
-
-
-
         // Cache the dropdown options
         var selectOptions = $dropdown.find("li");
 
@@ -91,11 +88,10 @@
             var $selected;
             if ($select.find(":selected").length) {
                 $selected = $select.find(":selected").last();
-            }
-            else {
+            } else {
                 $selected = $select.find("option, li").first();
-               // $selected = $select.find("option").first();
             }
+
             methods._select($dropdown, $selected);
         } else {
             var selectors = [], val = $select.val()
@@ -128,8 +124,6 @@
         // On click, set the clicked one as selected
         $ul.on("click", "li:not(.dropdownjs-add)", function(e) {
           methods._select($dropdown, $(this));
-          // trigger change event, if declared on the original selector
-          $select.change();
         });
         $ul.on("keydown", "li:not(.dropdownjs-add)", function(e) {
           if (e.which === 27) {
@@ -141,7 +135,6 @@
             return false;
           }
         });
-
         $ul.on("focus", "li:not(.dropdownjs-add)", function() {
           if ($select.is(":disabled")) {
             return;
@@ -183,8 +176,7 @@
             var $selected;
             if ($select.find(":selected").length) {
               $selected = $select.find(":selected").last();
-            }
-            else {
+            } else {
               $selected = $select.find("option, li").first();
             }
             methods._select($dropdown, $selected);
@@ -261,6 +253,7 @@
     },
     select: function(target) {
       var $target = $(this).find("[value=\"" + target + "\"]");
+      console.log("called from select");
       methods._select($(this), $target);
     },
     _select: function($dropdown, $target) {
@@ -280,10 +273,10 @@
         // Toggle option state
         $target.toggleClass("selected");
         // Toggle selection of the clicked option in native select
-        $target.each(function(){
+        $target.each(function() {
           var $selected = $select.find("[value=\"" + $(this).attr("value") + "\"]");
           $selected.prop("selected", $(this).hasClass("selected"));
-        })
+        });
         // Add or remove the value from the input
         var text = [];
         selectOptions.each(function() {
@@ -298,7 +291,7 @@
       if (!multi) {
         // Unselect options except the one that will be selected
         if ($target.is("li")) {
-            selectOptions.not($target).removeClass("selected");
+          selectOptions.not($target).removeClass("selected");
         }
         // Select the selected option
         $target.addClass("selected");
@@ -317,11 +310,10 @@
         }
       }
 
-       // Call the callback
-        if (this.options.onSelected) {
-            this.options.onSelected($target.attr("value"));
-        }
-
+      // Call the callback
+      if (this.options.onSelected) {
+        this.options.onSelected($target.attr("value"));
+      }
     },
     _addOption: function($ul, $this) {
       // Create the option

From aa6af20a9a9631452acf1d30886bb9d6c78fe51a Mon Sep 17 00:00:00 2001
From: Chris Trinh <ChrisT11@verifone.com>
Date: Thu, 12 May 2016 13:45:43 -0700
Subject: [PATCH 2/2] Remove console logging

---
 jquery.dropdown.js | 1 -
 1 file changed, 1 deletion(-)

diff --git a/jquery.dropdown.js b/jquery.dropdown.js
index 8f1327d..29c4bfe 100644
--- a/jquery.dropdown.js
+++ b/jquery.dropdown.js
@@ -253,7 +253,6 @@
     },
     select: function(target) {
       var $target = $(this).find("[value=\"" + target + "\"]");
-      console.log("called from select");
       methods._select($(this), $target);
     },
     _select: function($dropdown, $target) {
