Skip to content

Instantly share code, notes, and snippets.

@jasondentler
Created July 25, 2013 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasondentler/6080507 to your computer and use it in GitHub Desktop.
Save jasondentler/6080507 to your computer and use it in GitHub Desktop.
Scope autocomplete
<div class="control-group">
@Html.LabelFor(m => m.Scope, new {@class = "control-label"})
<div class="controls">
@Html.TextBoxFor(m => m.Scope)
</div>
</div>
@section scripts
{
<script>
$(function() {
var scopeId = '#@Html.IdFor(m => m.Scope)';
var scopeAutocompleteUrl = @Html.Raw(Json.Encode(Url.Action("ScopeAutocomplete", "Sub")));
$(scopeId).typeahead({
source: function(query, process) {
return $.get(scopeAutocompleteUrl, { query: query }, function(data) {
return process(data);
});
}
});
});
</script>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment