我有一個MVC3應用程序, 我知道,對於相對路徑,我可以在我的.aspx視圖中使用Url.Content。如何在jQuery和MVC中處理相對路徑,例如DatePicker
但是,如何在jQuery中做類似的事情?我正在看的是jquery-ui datepicker,例如我有我的datetimem DateTime.ascx以下EditorTemplate:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime>" %>
<%: Html.TextBox("", this.Model.ToString("MM/dd/yyyy"), new { @class="datepicker"}) %>
<script type="text/javascript">
$(document).ready(function() {
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'mm/dd/yy',
gotoCurrent: true,
showOn: 'button',
buttonImageOnly: true,
buttonImage: '../../../Content/images/calendar.png' // WHAT DO I PUT HERE?
});
});
</script>
感謝,
我不認爲這是可行的(但我測試,它也!),例如buttonImage:'<%= Url.Content(「〜/ Content/images/calendar.png」)%>'...是不是Url.Content MVC特定?所以如果我想在非MVC應用程序中重用這個庫,我會遇到麻煩,不是嗎? – Raymond 2011-05-26 22:54:13