2012-01-09 2 views
2

자동 완료 위젯을 사용하여 liftScreen에서 사용자에게 필요한 입력 사항을 표시합니다. 나는 자동 완성의 선택된 옵션으로 페이지의 내용을 변경해야합니다.자동 완성 변경 페이지 콘텐츠

자동 완성 위젯이 가능합니까?

예를 게시하십시오.

/*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> 
}  
: 여기

답변

2

자동 완성와 Ajax의 예
관련 문제