summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Margheim <stephen.margheim@gmail.com>2015-11-23 18:53:08 -0500
committerStephen Margheim <stephen.margheim@gmail.com>2015-11-23 18:53:08 -0500
commit6a303794fc06b5adcd091d0367c587e02944700f (patch)
tree387b60c031ade4b8c4b23246a7617393aac93671
parent6b4026e0384a84fe620899fa0f13feeba81f35cf (diff)
downloadawesomplete-6a303794fc06b5adcd091d0367c587e02944700f.zip
awesomplete-6a303794fc06b5adcd091d0367c587e02944700f.tar.gz
awesomplete-6a303794fc06b5adcd091d0367c587e02944700f.tar.bz2
Add toggle API method
-rw-r--r--awesomplete.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/awesomplete.js b/awesomplete.js
index a422d1b..2055fc5 100644
--- a/awesomplete.js
+++ b/awesomplete.js
@@ -120,6 +120,7 @@ _.prototype = {
this._list = list.split(/\s*,\s*/);
}
else { // Element or CSS selector
+ console.log('list type unknown');
list = $(list);
if (list && list.children) {
@@ -159,6 +160,19 @@ _.prototype = {
$.fire(this.input, "awesomplete-open");
},
+ toggle: function () {
+ if (this.ul.childNodes.length == 0) {
+ this.minChars = 0;
+ this.evaluate();
+ }
+ else if (this.ul.hasAttribute('hidden')) {
+ this.open();
+ }
+ else {
+ this.close();
+ }
+ },
+
next: function () {
var count = this.ul.children.length;