Hello there Tek-Tips experts.
im using ajax/jquery to apply stripes to alternative lines on a table of products, as below:
<script>
$(function () {
$('#target2').bind('keyup', function () {
$('#form').delay(700).submit();
});
$("#form").submit(function (event) {
event.preventDefault();
$.ajax
({
url: "Sops/SearchResults",
datatype: "html",
type: "post",
data: $("#form").serialize(),
success: function (stockData) {
$("#myProds").html(stockData.viewModel).hide().fadeIn();
}
});
return false;
});
$("#myProds tr:even").css("background-color", "silver");
$("#myProds a").live("click", function () {
$.get($(this).attr("href"), function (response) {
$("#myProds").replaceWith($("#myProds", response));
$("#myProds tr:even").css("background-color", "silver");
});
return false;
});
});
</script>
the first part filters as the user types into a search box, the second reapplies the stripes and does some async updates on page changes.
all this works except that when i filter on the products, i lose the stripes.
is there a way to format this so that the stripes get reapplied after the filtering has taken place?
apologies if there is not enough information or if i have missed something crucial. please let me know what you need to further troubleshoot this.
by the way, im using MVC C#, in case it is relevent.
Thanks for reading.
im using ajax/jquery to apply stripes to alternative lines on a table of products, as below:
<script>
$(function () {
$('#target2').bind('keyup', function () {
$('#form').delay(700).submit();
});
$("#form").submit(function (event) {
event.preventDefault();
$.ajax
({
url: "Sops/SearchResults",
datatype: "html",
type: "post",
data: $("#form").serialize(),
success: function (stockData) {
$("#myProds").html(stockData.viewModel).hide().fadeIn();
}
});
return false;
});
$("#myProds tr:even").css("background-color", "silver");
$("#myProds a").live("click", function () {
$.get($(this).attr("href"), function (response) {
$("#myProds").replaceWith($("#myProds", response));
$("#myProds tr:even").css("background-color", "silver");
});
return false;
});
});
</script>
the first part filters as the user types into a search box, the second reapplies the stripes and does some async updates on page changes.
all this works except that when i filter on the products, i lose the stripes.
is there a way to format this so that the stripes get reapplied after the filtering has taken place?
apologies if there is not enough information or if i have missed something crucial. please let me know what you need to further troubleshoot this.
by the way, im using MVC C#, in case it is relevent.
Thanks for reading.