Created
May 11, 2015 22:37
-
-
Save terrycojones/364c3df9956000f9545a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wsuri = "ws://127.0.0.1:8080/ws"; | |
var connection = new autobahn.Connection({ | |
url: wsuri, | |
realm: "realm1", | |
use_deferred: jQuery.Deferred | |
}); | |
var jqueryReady = jQuery.Deferred(); | |
var routerReady = jQuery.Deferred(); | |
jQuery.when(routerReady, jqueryReady).done(function(session){ | |
jQuery("#searchbox").autocomplete({ | |
source: function(request, response) { | |
session.call('search-function', request).then( | |
function(result){ | |
// Massage result into a list of strings, if necessary. | |
response(result); | |
}, | |
function(error){ | |
// Some kind of server error. Must still call response. | |
response([]); | |
} | |
); | |
} | |
}); | |
}); | |
jQuery(document).ready(jqueryReady.resolve); | |
connection.onopen = function (session, details) { | |
routerReady.resolve(session); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment