Created
February 2, 2012 16:51
-
-
Save abdullin/1724522 to your computer and use it in GitHub Desktop.
Snippet that does AJAX search over a denormalized projection (handled by server) in async
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
// Snippet that shows AJAX search over a denormalized projection (handled by server) in async | |
// for sending commands in async - just do the AJAX post to server | |
// for getting changes - just poll the server for view version | |
// for cases when polling is expensive - use web sockets. | |
<script type="text/javascript"> | |
$(document).ready(function () { | |
$('#searchButton').click(function () { | |
GetData($('#searchbox').val()); | |
}); | |
$('#searchbox').keydown(function (event) { | |
if (event.keyCode != '13') return; | |
GetData($('#searchbox').val()); | |
}); | |
$('#activitiesTab').addClass('active'); | |
$('#searchbox').focus(); | |
GetData(); | |
}); | |
// I heard that people use Lucene for full-text search. | |
// we just use projections stored as files (or cloud blobs) | |
// and implemented with dozen of lines of code. | |
function GetData(term) { | |
$('#data-box').text('Searching...'); | |
$.post('/system/ActivitiesData', { searchTerm : term }, function (data) { | |
$('#data-box').html(data); | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment