aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/autocomplete.js
diff options
context:
space:
mode:
authorStefan Parviainen <saparvia@caterva.eu>2015-01-07 21:32:17 +0100
committerStefan Parviainen <saparvia@caterva.eu>2015-01-07 21:32:17 +0100
commitd7a3d9f60654a721cb00d78dd653fd56e4e9fb53 (patch)
treebd40ad4db6a69af5daf680ddbe851a524e4aa903 /view/js/autocomplete.js
parentfcc9131fb9b1a0c115823c42a0828ce25670b215 (diff)
downloadvolse-hubzilla-d7a3d9f60654a721cb00d78dd653fd56e4e9fb53.tar.gz
volse-hubzilla-d7a3d9f60654a721cb00d78dd653fd56e4e9fb53.tar.bz2
volse-hubzilla-d7a3d9f60654a721cb00d78dd653fd56e4e9fb53.zip
Add autosubmit feature to textcomplete based autocompleter
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r--view/js/autocomplete.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 26d3f6211..afdf9c230 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -43,6 +43,10 @@ function basic_replace(item) {
return '$1'+item.name+' ';
}
+function submit_form(e) {
+ $(e).parents('form').submit();
+}
+
/**
* jQuery plugin 'editor_autocomplete'
*/
@@ -86,14 +90,18 @@ function basic_replace(item) {
template: contact_format,
}
this.attr('autocomplete','off');
- this.textcomplete([contacts],{className:'acpopup'});
+ var a = this.textcomplete([contacts],{className:'acpopup'});
+
+ a.on('textComplete:select', function(e,value,strategy) { submit_form(this); });
+
};
})( jQuery );
(function( $ ){
- $.fn.contact_autocomplete = function(backend_url, typ, onselect) {
+ $.fn.contact_autocomplete = function(backend_url, typ, autosubmit, onselect) {
if(typeof typ === 'undefined') typ = '';
+ if(typeof autosubmit === 'undefined') autosubmit = false;
// Autocomplete contacts
contacts = {
@@ -107,6 +115,9 @@ function basic_replace(item) {
this.attr('autocomplete','off');
var a = this.textcomplete([contacts],{className:'acpopup'});
+ if(autosubmit)
+ a.on('textComplete:select', function(e,value,strategy) { submit_form(this); });
+
if(typeof onselect !== 'undefined')
a.on('textComplete:select',function(e,value,strategy) { onselect(value); });
};