0

I want to export an array of names to be accessible by jQuery UI for autocompletion.

I defined an array:

  @(JSExport @field)
  val possibleNames = Array("AB", "CD", "ED") 

and tried to use it in JavaScript:

$("#NameInput").autocomplete(
    { source: example.NameTest().possibleNames }
);

However this give me an error:

TypeError: this.source is not a function

this.source( { term: value }, this._response() );

I tried to export a function like

  @JSExport 
 def testFunction(): Array[String] = {
       Array("AB", "CD", "ED") 
  }

But the result is the same.

Any ideas what to do?

Community
  • 1
  • 1
Klaus Schulz
  • 527
  • 1
  • 5
  • 20

1 Answers1

1

That happens because an Array is not a JavaScript array that jQuery can understand. You need to export a js.Array instead.

sjrd
  • 21,805
  • 2
  • 61
  • 91