falsecz
10/3/2012 - 1:48 PM

gistfile1


input = document.getElementById("txtInput");

class M extends goog.ui.ac.RemoteArrayMatcher
	constructor: ->
		super
		@_matchHandler = null
		
	setUrlFunction: (@_urlFunction) ->
		
	buildUrl: (uri, token, maxMatches, useSimilar, opt_fullString)->
		@_urlFunction token
		// accessToken = builder.api.facebook.getInstance().getAccessToken()
		// "https://graph.facebook.com/search?q=#{token}&type=adregion&access_token=#{accessToken}"
	requestMatchingRows: (token, maxMatches, matchHandler) ->
		myMatchHandler = (token, matches) ->
			console.log token,matches
			rows = []
			for r in matches.data
				rows.push r.name
			matchHandler token, rows
		super token, maxMatches, myMatchHandler


matcher = new M "xxx"

renderer = new goog.ui.ac.Renderer
			
inputHandler = new goog.ui.ac.InputHandler null, null, false
autoComplete = new goog.ui.ac.AutoComplete matcher, renderer, inputHandler
inputHandler.attachAutoComplete autoComplete
inputHandler.attachInputs input



m = new builder.ui.AutoComplete
m.attachInput input
m.setUrlFunction (token) -> "http:///#{token}"
m.setMatchHandler (token, matches) -> 
	console.log token,matches
	rows = []
	for r in matches.data
		rows.push r.name
		matchHandler token, rows
	rows