From 133753350bb83a87eac049c67a10db58aff73ca6 Mon Sep 17 00:00:00 2001 From: Rolux Date: Fri, 19 Feb 2010 16:04:51 +0530 Subject: [PATCH] autocomplete, continued --- build/js/ox.ui.js | 21 ++++++++++++++------- demos/test/index.html | 5 +++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 74520f24..647c629a 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -1564,10 +1564,10 @@ requires if (self.options.label) { self.options.label = Ox.makeArray(self.options.label); - self.label = self.options.label[0]; + self.label = self.options.label[self.options.selected]; } else if (self.options.placeholder) { self.options.placeholder = Ox.makeArray(self.options.placeholder); - self.placeholder = self.options.placeholder[0]; + self.placeholder = self.options.placeholder[self.options.selected]; } if (Ox.isArray(self.options.autocomplete)) { autocomplete = self.options.autocomplete; @@ -1596,7 +1596,11 @@ requires group: self.placeholderId, // fixme: same id, works here, but should be different title: title }; - }) + }), + offset: { + left: 4, + top: 0 + } }); that.bindEvent("change_" + self.placeholderId, changePlaceholder); } @@ -1650,7 +1654,7 @@ requires value = value.toLowerCase(); var items = []; if (value === "") { - items = self.options.autocomplete[self.placeholder]; + // items = self.options.autocomplete[self.placeholder]; } else { $.each(self.options.autocomplete[self.placeholder], function(i, item) { if (item.toLowerCase().indexOf(value) > -1) { @@ -1699,11 +1703,12 @@ requires } function cancel() { - that.$input.trigger("blur"); + that.$input.blur(); } function clear() { - that.$input.val(""); + that.$input.val("").focus(); + //call(); } function change() { @@ -1715,8 +1720,10 @@ requires self.placeholder = data.value; // fixme: could be "title" as well if (that.$input.is(".OxPlaceholder")) { that.$input.val(self.placeholder); + } else { + that.$input.focus(); + call(); } - call(); } function blur() { diff --git a/demos/test/index.html b/demos/test/index.html index 85b54962..88d15d91 100644 --- a/demos/test/index.html +++ b/demos/test/index.html @@ -398,8 +398,9 @@ clear: true, highlight: true, id: "citystate", - placeholder: ["City", "State"] - }).addClass("margin").width(128).appendTo(mainPanel); + placeholder: ["City", "State"], + selected: 1 + }).addClass("margin").width(160).appendTo(mainPanel); //*/ function switchTheme() { if (Ox.theme() == "classic") {