I'm using Asp.NET MVC and have a huge dependency on JQuery throughout my entire application (not sure if that's important here or not). I'm trying to build a set of js library files to go along side my views. The problem that I'm faced with is that I need a way to manage the server side location of my files and action links for all of my image maps and ajax calls.
For now, I'm stuck putting all of my scripting code inside each aspx pages so that I can use the server side scripting tags like this:
$("#StartDate").datepicker({
changeMonth: true,
changeYear: true,
showOn: 'button',
buttonImage: '<%= Url.Content("~/Content") %>/Images/calendar.png',
buttonImageOnly: true
});
and
function fillDates(periodType, periodOffset)
{
$.ajax({
url: '<%= Url.Action("GetDates", "Tracking") %>',
dataType: "json",
data: {"pt": periodType, "po": periodOffset},
success: function(result){
if (result.Status == "Success")
{
$("#StartDate").val(result.StartDate);
$("#EndDate").val(result.EndDate);
}
else
{
alert(result.Status + ": " + result.Message);
}
}
});
}
I'd like to move this code to a js file. How would I do this and still be able to map to the root directory of my application.