Skip to content

Instantly share code, notes, and snippets.

@butaji
Created February 21, 2011 13:06
Show Gist options
  • Save butaji/837036 to your computer and use it in GitHub Desktop.
Save butaji/837036 to your computer and use it in GitHub Desktop.
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Поиск по узлу
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
function loadFormWithHash() {
$.get('<%= Url.Action("SearchForm","Person") %>?' + window.location.hash.slice(1),
function (data) {
$('#searchContainer').html(data);
}
);
}
function loadResultsWithHash() {
$.get('<%= Url.Action("SearchResults","Person") %>?' + window.location.hash.slice(1),
function (data) {
$('#searchResults').html(data);
}
);
}
$(function () {
if (window.location.hash) {
loadFormWithHash();
loadResultsWithHash();
} else {
$.get('<%= Url.Action("SearchForm","Person", ViewData.Model) %>',
function (data) {
$('#searchContainer').html(data);
}
);
$.get('<%= Url.Action("SearchResults","Person", ViewData.Model) %>',
function (data) {
$('#searchResults').html(data);
}
);
}
$('#searchContainer>form').live("submit", function () {
$('#searchResults').html("Загрузка...");
var parameters = $(this).serialize();
window.location.hash = parameters;
loadResultsWithHash();
return false;
});
});
</script>
<h2>
Форма поиска</h2>
<div id="searchContainer">
Загрузка...
</div>
<h2>
Форма результатов поиска</h2>
<div id="searchResults">
Загрузка...
</div>
</asp:Content>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment