summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/source
diff options
context:
space:
mode:
authorDavid <ottodavid@gmx.net>2014-11-21 22:14:00 +0100
committerDavid <ottodavid@gmx.net>2014-11-21 22:14:00 +0100
commit6d52f5c4461bd26c4e1dea68686d88c71a9d3e22 (patch)
treed629ca00a7d2a902d5d7e6724abda9f7bbcbcc8a /framework/Web/Javascripts/source
parentac6eeca7dedbd74a60f507a8e7ec345394fb90aa (diff)
TJuiAutoComplete multiselection + quickstart doc
implemented Separator, minChars and Frequency properties, added the related quickstart parts
Diffstat (limited to 'framework/Web/Javascripts/source')
-rw-r--r--framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js
index 0a7511c1..5d4beef8 100644
--- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js
+++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js
@@ -103,7 +103,12 @@ Prado.WebUI.TJuiAutoComplete = jQuery.klass(Prado.WebUI.TActiveTextBox,
this.hasResults = false;
jQuery.extend(this.options, {
source: this.getUpdatedChoices.bind(this),
- select: this.selectEntry.bind(this)
+ select: this.selectEntry.bind(this),
+ focus: function () {
+ return false;
+ },
+ minLength: this.options.minLength,
+ frequency: this.options.frequency
});
jQuery('#'+options.ID).autocomplete(this.options)
.data( "ui-autocomplete")._renderItem = function( ul, item ) {
@@ -131,22 +136,38 @@ Prado.WebUI.TJuiAutoComplete = jQuery.klass(Prado.WebUI.TActiveTextBox,
getUpdatedChoices : function(request, callback)
{
- var params = new Array(request.term,"__TJuiAutoComplete_onSuggest__");
+ var lastTerm = this.extractLastTerm(request.term);
+ var params = new Array(lastTerm, "__TJuiAutoComplete_onSuggest__");
var options = jQuery.extend(this.options, {
'autocompleteCallback' : callback
});
Prado.Callback(this.options.EventTarget, params, this.onComplete.bind(this), this.options);
},
+ extractLastTerm: function(string)
+ {
+ var re = new RegExp("[" + this.options.Separators + "]");
+ return string.split(re).pop().trim();
+ },
+
/**
* Overrides parent implements, don't update if no results.
*/
- selectEntry: function(event, ui)
- {
+ selectEntry: function(event, ui) {
+ var value = event.target.value;
+ var lastTerm = this.extractLastTerm(value);
+
+ // strip (possibly) incomplete last part
+ var previousTerms = value.substr(0, value.length - lastTerm.length);
+ // and append selected value
+ ui.item.value = previousTerms + ui.item.value;
+
+ //ui.item.value = event.target.value;
var options = [ui.item.id, "__TJuiAutoComplete_onSuggestionSelected__"];
Prado.Callback(this.options.EventTarget, options, null, this.options);
},
+
onComplete : function(request, result)
{
var that = this;