question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autocomplete updateData() with http reqests

See original GitHub issue

Hi! I have a problem with autocomplete.updateData()

 <div class="input-field" style="padding:0px;margin-top:0em;margin-bottom:0em">
  <input type="text" placeholder="podaj kod towaru" id="pozycje_autocomplete"
     (change)="selectTowar($event)" autocomplete="off" class="autocomplete" name="kodTowaru" [(ngModel)]="kodTowaru"
     (keyup.Enter)="dodajPozycje()" (keyup)="szukajTowary($event)" style="text-align:center;height:2em">
 </div>

It’s all about (keyup)="szukajTowaru($event)"

  ngAfterViewInit() {
    const pozycje_autocomplete = document.querySelector('#pozycje_autocomplete');
    M.Autocomplete.init(pozycje_autocomplete, {
      limit: 5
    });
}

  szukajTowary(event:any)
  {
    const pozycje_autocomplete = document.querySelector('#pozycje_autocomplete');
    let instance = M.Autocomplete.getInstance(pozycje_autocomplete);

    this.http.get('http://192.168.0.110:9000/tron/towary/'+event.target.value)
      .subscribe((result: any[]) => {
        let pozycje = [];
        for (var i = 0; i < result.length; i++) {
          pozycje[result[i]] = null;
        }
        console.log(pozycje);
        instance.updateData(pozycje);
      });
  }

Console.log displays data correctly when I type, for example, letter ‘s’

[IGLAKI_CYPRYS: null, KORA_S80: null, PIŁA_SPALINOWA: null, SEKATOR: null, SKRZYNKA: null, …]
IGLAKI_CYPRYS: null
KORA_S80: null
PIŁA_SPALINOWA: null
SEKATOR: null
SKRZYNKA: null
STOJAK: null
SZPADEL: null
ZESTAW_OGR: null
length: 0
__proto__: Array(0)

It’s not showing autocomplete dropdown. Sometimes after couple tries it works but it’s messed up with items from request before.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:20

github_iconTop GitHub Comments

3reactions
troncomputerscommented, Jan 16, 2020

@Dahkon this issue is almost 2 years old. Last release is from September 9th, 2018. I think this framework is dead…

2reactions
Smankusorscommented, Dec 14, 2020

👍

@samijnih Please do not comment with emoji only, like your other 5 comments. You’re spamming someone’s inbox. Please use the reactions instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AutoComplete use with http response - jquery - Stack Overflow
I need to create autocomplete input in MVC application to get data by $http request. after three later type request must be functioning...
Read more >
Populating autocomplete with Sources - Algolia
You can access the autocomplete state in your sources, meaning you can search within static sources to update them as the user types....
Read more >
Place Autocomplete | Places API - Google Developers
The Place Autocomplete service is a web service that returns place predictions in response to an HTTP request. The request specifies a textual...
Read more >
Autocomplete Widget - jQuery UI API Documentation
While requesting data to display to the user, the ui-autocomplete-loading class ... Unlike other widget methods, instance() is safe to call on any...
Read more >
AutoComplete Textbox in Angular 6 with Dynamic Data using ...
AutoComplete Textbox in Angular 6 with Dynamic Data using Web API in MVC 4 ... has a single public method called Get(), which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found