I am using MVC3 on my project.
I have a view with a bunch of DDL’s, Search Button and a Table.
User can choose values and then hit the search button and the table will show all data that got hit.
This is my jquery code for the search button click:
$(function () {
$('#submitfloat').click(function () {
var SubjectTypes = $('#SubjectTypes').val();
var Teams = $('#Teams').val();
var Companies = $('#Companies').val();
var Consultants = $('#Consultants').val();
var PlannedDates = $('#PlannedDates').val();
var CompletedDates = $('#CompletedDates').val();
var DateTypes = $('#DateTypes').val();
var data = {
Subjectypes: SubjectTypes,
Companies: Companies,
Teams: Teams,
Consultants: Consultants,
PlannedDates: PlannedDates,
CompletedDates: CompletedDates,
DateTypes: DateTypes
};
$.post('@Url.Action("Search", "SearchNKI")', data, function (result) {
$("#GoalcardSearchResult tbody").html('');
result.forEach(function (goalcard) {
$("#GoalcardSearchResult tbody").append(
$('<tr/>', {
click: function () {
// todo: redirect
alert(goalcard.Id);
},
html: "<td>" + goalcard.Name + "</td><td>" + goalcard.Customer + "</td><td>" + goalcard.PlannedDate + "</td><td>" + goalcard.CompletedDate + "</td>"
}));
});
});
return false;
});
});
This is my Controller:
[HttpPost]
public JsonResult Search(SearchQueryViewModel model)
{
var goalcard = SearchRep.FindGoalCard(model); // My LINQ
return Json(goalcard.Select(x => new GoalCardViewModel(x)));
}
Everything works fine but when I add my Jquery Table Sorter:
<script type="text/javascript">
$(document).ready(function () {
$("#GoalcardSearchResult").tablesorter();
});
</script>
I get this wall of Json text when I click on the Search button:
![][1]
[1]:
I have no idea why this happens, when I debug my search button click jquery code its not even getting executed when I add the Table Sorter jquery code. Anyone have any idea what the cause is?
All I know is that when I add the Table Sorter, it blocks my button click jquery code from running and jumps directly to the server-side and returns json.
Thanks in advance!
It was a modified Table Sorter code, with some minor changes I got it running