поднять автозаполнение изменить содержание страницы - PullRequest
2 голосов
/ 09 января 2012

Я использую автозаполнение виджета, чтобы показать необходимые входные данные для пользователя на экране лифта. Мне нужно изменить содержание страницы с выбранной опцией автозаполнения.

Возможно ли с виджетом автозаполнения?

Если это, пожалуйста, опубликуйте пример.

1 Ответ

2 голосов
/ 11 февраля 2012

Вот пример Autocomplete и Ajax:

/*Create a ValueCell to update*/
val cell = ValueCell("")

/* Do a basic ajaxText */
val nameAjax = SHtml.ajaxText(cell.get, s=>{ cell.set(s); Noop})

/* Make attributes out of it */
val attrs: Seq[(String,String)] = nameAjax.attributes.toList.map{md => (md.key,md.value.text)}

/* Do the basic autocomplete with your attibutes */
def query(s:String):List[String] /*Do the query to get the desired autocomplete values */
def buildQueryName(current: String, limit: Int): Seq[String] = {
  if (current.length == 0) Nil
  else query(current).take(limit) /*query representing
}
private def processResult(s : String) {}

/* Function to render the autocomplete box */
def autoCompleteBox = AutoComplete("", buildQueryName _, processResult _ , attrs:_* )

/* function to render the dynamic part */
def dynamicPart = WiringUI.apply(cell)(createDynamicPart)

def createDynamicPart(value:String)(ns:NodeSeq):NodeSeq ={
  <h3> value selected: {value} </h3>
}    
...