jquery - Not getting suggestion in between the text -


when continuously type , auto suggestions when try enter text in between text didnot suggestion suggestion please.. here code:

(type the is , try add text between the , is)

html

<textarea id="textbox"></textarea> 

jquery

function autosuggestcontrol(id_or_element /*:htmlinputelement*/) {     this.provider /*:suggestionprovider*/ = new wordsuggestions();     this.textbox /*:htmlinputelement*/ = typeof id_or_element == "string" ? document.getelementbyid(id_or_element) : id_or_element;     this.init();  }   autosuggestcontrol.prototype.autosuggest = function (asuggestions /*:array*/) {      //make sure there's @ least 1 suggestion      if (asuggestions.length > 0) {         this.typeahead(asuggestions[0]);     } };  autosuggestcontrol.prototype.handlekeyup = function (oevent /*:event*/) {      var ikeycode = oevent.keycode;     var evtobj = oevent;     window.eventobj = evtobj;     if ((ikeycode != 16 && ikeycode < 32) || (ikeycode >= 33 && ikeycode <= 46) || (ikeycode >= 112 && ikeycode <= 123) || (ikeycode == 65 && evtobj.ctrlkey) || (ikeycode == 90 && evtobj.ctrlkey)) {         //ignore         if (ikeycode == 90 && evtobj.ctrlkey) {             // window.getselection().deletefromdocument();             // todo: need find way select rest of text , delete.         }     } else {         //request suggestions suggestion provider         this.provider.requestsuggestions(this)     } };   autosuggestcontrol.prototype.init = function () {      //save reference object     var othis = this;     //assign onkeyup event handler     lastdate = new date();     othis.textbox.onkeyup = function (oevent) {          //check proper location of event object         if (!oevent) {             oevent = window.event;         }         newdate = new date();         if (newdate.gettime() > lastdate.gettime() + 200) {             othis.handlekeyup(oevent);             lastdate = newdate;         }     };  };  autosuggestcontrol.prototype.selectrange = function (istart /*:int*/, ilength /*:int*/) {     //use text ranges internet explorer     if (this.textbox.createtextrange) {         var orange = this.textbox.createtextrange();         orange.movestart("character", istart);         orange.moveend("character", ilength);         orange.select();         //use setselectionrange() mozilla     } else if (this.textbox.setselectionrange) {         this.textbox.setselectionrange(istart, ilength);     }     //set focus textbox     $('#textbox').focus().val($('#textbox').val());     // this.textbox.focus(); };   autosuggestcontrol.prototype.typeahead = function (ssuggestion /*:string*/) {      //check support of typeahead functionality     if (this.textbox.createtextrange || this.textbox.setselectionrange) {         var lastspace = this.textbox.value.lastindexof(" ");         var lastquote = this.textbox.value.lastindexof("'");         var lasthypen = this.textbox.value.lastindexof("-");         var lastdoublequote = this.textbox.value.lastindexof('"');         var lastenter = this.textbox.value.lastindexof("\n");         var lastindex = math.max(lastspace, lastenter, lastquote, lasthypen, lastdoublequote) + 1;         var contentstripped = this.textbox.value.substring(0, lastindex);         var lastword = this.textbox.value.substring(lastindex, this.textbox.value.length);         this.textbox.value = contentstripped + ssuggestion; //.replace(lastword,"");         var start = this.textbox.value.length - ssuggestion.replace(lastword, "").length;         var end = this.textbox.value.length;         this.selectrange(start, end);     } };   wordsuggestions.prototype.requestsuggestions = function (oautosuggestcontrol /*:autosuggestcontrol*/) {     var asuggestions = [];     var stextbox = oautosuggestcontrol.textbox.value;     var stextboxsplit = stextbox.split(/[\s,]+/);     var stextboxlast = stextboxsplit[stextboxsplit.length - 1];     var stextboxvalue = stextboxlast;     if (stextboxvalue.length > 0) {         //search matching words         (var = 0; < this.words.length; i++) {             if (this.words[i].indexof(stextboxvalue.tolowercase()) == 0) {                 if (this.words[i].indexof(stextboxvalue) == 0) {                     asuggestions.push(this.words[i]);                 }                 else if (this.words[i].indexof(stextboxvalue.charat(0).tolowercase() + stextboxvalue.slice(1)) == 0) {                     asuggestions.push(this.words[i].charat(0).touppercase() + this.words[i].slice(1));                 }             }         }     }     debugger;     //provide suggestions control     oautosuggestcontrol.autosuggest(asuggestions); };  function wordsuggestions() {     this.words = ['the', 'and', 'that', 'for', 'with', 'yo', 'are', 'your', 'from', 'have', 'more', 'but', 'new', 'not', 'will', 'what', 'about', 'all', 'one', 'they', 'get', 'like', 'out', 'their', 'who', 'people', 'been', 'can', 'how', 'there', 'which', 'were', 'apple', 'time', 'when', 'just', 'into', 'said', 'our', 'here', 'also', 'year', 'view', 'these', 'comment', 'had', 'would', 'other', 'now', 'than', 'she', 'see', 'after', 'most', 'some', 'make', 'points', 'her', 'mobile', 'day', 'insider', 'point', 'company', 'over', 'twitter', 'use', 'right', 'say', 'could', 'them', 'way', 'first', 'why', 'ago', 'world', 'thing', 'only', 'login', 'even', 'before', 'because', 'any', 'two', 'million', 'please', 'device', 'service', 'phone', 'made', 'topic', 'while', 'best', 'work', 'last', 'know', 'network', 'read', 'him', 'much', 'want', 'those', 'where', 'follow', 'user', 'friend', 'may', 'then', 'going', 'still', 'well', 'look', 'being', 'post', 'think', 'photo', 'hour', 'many', 'take', 'image', 'back', 'got', 'video', 'should', 'off', 'very', 'site', 'come', 'good', 'recently', 'need', 'down', 'did', 'show', 'email', 'open', 'around', 'really', 'week', 'policy', 'using', 'through', 'big', 'today', 'game', 'alert', 'article', 'stock', 'too', 'media', 'next', 'product', 'find', 'android', 'own', 'during', 'free', 'market', 'story', 'lot', 'reading', 'term', 'social', 'feel', 'technology', 'share', 'every', 'able', 'shared', 'since', 'question', 'life', 'state', 'inc', 'home', 'few', 'told', 'never', 'president', 'data', 'something', 'job', 'house', 'report', 'used', 'better', 'another', 'window', 'city', 'according', 'content', 'system', 'via', 'part', 'government', 'same', 'help', 'man', 'let', 'both', 'disrupt', 'privacy', 'top', 'software', 'tech', 'number', 'percent', 'long', 'each', 'such', 'inside', 'car', 'line', 'month', 'three', 'actually', 'doe', 'live', 'end', 'money', 'might', 'billion', 'without', 'experience', 'little', 'found', 'future', 'great', 'school', 'put', 'information', 'between', 'already', 'must', 'case', 'quote', 'feature', 'though', 'ever', 'page', 'plan', 'including', 'tags', 'call', 'called', 'making', 'police', 'copyright', 'web', 'mean', 'change', 'password', 'seem', 'white', 'serving', 'powered', 'ask', 'reserved', 'idea', 'logged', 'tell', 'against', 'problem', 'give', 'working', 'learn', 'full', 'startup', 'continue', 'doing', 'team', 'acceptance', 'constitute', 'forgot', 'national', 'set', 'tablet', 'run', 'consumer', 'fact', 'yet', 'love', 'different', 'name', 'far', 'cant', 'women', 'registration', 'place', 'least', 'disclaimer', 'sale', 'directly', 'become', 'getting', 'real', 'update', 'party', 'play', 'advertising', 'writer', 'high', 'group', 'turn', 'keep', 'public', 'enough', 'ready', 'second', 'republican', 'health', 'everyone', 'once', 'away', 'pay', 'under', 'years', 'browser', 'five', 'past', 'buy', 'deal', 'old', 'left', 'store', 'former', 'small', 'early', 'computer', 'law', 'based', 'guy', 'looking', 'bad', 'office', 'covered', 'price', 'design', 'kind', 'bit', 'support', 'offer', 'search', 'note', 'person', 'start', 'likely', 'advertise', 'reason', 'guest', 'having', 'sure', 'took', 'hardware', 'per', 'screen', 'bill', 'respect', 'blog', 'space', 'taking', 'probably', 'platform', 'war', 'key', 'john', 'power', 'again', 'someone', 'seen', 'later', 'men', 'watch', 'family', 'hand', 'important', 'website', 'employee', 'version', 'however', 'care', 'believe', 'pretty', 'marketing', 'went', 'issue', 'official', 'trying', 'until', 'started', 'night', 'course', 'china', 'alway', 'intelligence', 'add', 'guideline', 'customer', 'instead', 'everything', 'security', 'current', 'building', 'asked', 'sign', 'anonymity', 'brand', 'hard', 'whether', 'country', 'coming', 'digital', 'revenue', 'manually', 'mac', 'scoop', 'amazon', 'wont', 'examples', 'gun', 'strong', 'four', 'hit', 'include', 'thought', 'latest', 'submitting', 'review', 'huge', 'launch', 'order', 'student', 'available', 'following', 'word', 'markup', 'coded', 'pro', 'especially', 'death', 'done', 'children', 'style', 'maybe', 'daily', 'credit', 'camera', 'talk', 'kid', 'control', 'below', 'among', 'came', 'example', 'event', 'blackberry', 'street', 'cost', 'fire', 'woman', 'picture', 'yahoo', 'industry', 'model', 'developer', 'black', 'running', 'source', 'anything', 'together', 'simply', 'major', 'this', 'commerce', 'book', 'allow', 'quarter', 'growth', 'behind', 'biggest', 'member', 'pap', 'business', 'chart', 'move', 'provide', 'court', 'face', 'almost', 'tax', 'stop', 'music', 'create', 'given', 'several', 'recent', 'university', 'project', 'map', 'display', 'lead', 'head', 'try', 'air', 'popular', 'thank', 'young', 'result', 'known', 'gay', 'program', 'account', 'side', 'invest', 'cut', 'star', 'wanted', 'release', 'images', 'possible', 'list', 'act', 'college', 'anyone', 'history', 'often', 'earlier', 'link', 'focused', 'sheet', 'saw', 'shot', 'clear', 'either', 'worked', 'message', 'area', 'dead', 'center']; }        $(document).ready(function(){                   var otextbox = new autosuggestcontrol("textbox");                   }); 


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -