我有我的页面调用如下的局部视图: -
@Html.Partial("~/Views/Shared/ImageGallery.cshtml", Model)
本页面的实际Jquery的代码如下: -
<script type="text/javascript">
$(document).ready(function () {
$('.modal_block').click(function (e) {
$('#tn_select').empty();
$('.modal_part').hide();
});
$('#modal_link').click(function (e) {
$('.modal_part').show();
var context = $('#tn_select').load('/Upload/UploadImage?Page=Article&Action=Edit&id=16', function () {
initSelect(context);
});
e.preventDefault();
return false;
});
});
</script>
现在,这个完美的作品,但我需要找到一种方式来传递动态VAR,而不是硬编码瓦尔这样: -
Upload/UploadImage?Page=Article&Action=Edit&id=16
在模型我把所有的增值经销商,但我不知道我怎样才能将它们插入到Jquery的。 任何帮助将非常感谢!
--------- UPDATE -----------------------
这是我投入需要的ImageGallery每个CSHTML的代码。
</div>
@Html.HiddenFor(model => model.PageViewModel.Page.PageTitle, new { id = "PageTitle"});
@Html.HiddenFor(model => model.PageViewModel.Page.PageAction, new { id = "PageAction"});
@Html.HiddenFor(model => model.ArticleViewModel.Article.ArticleID, new { id = "ArticleID"});
<div>
@Html.Partial("~/Views/Shared/ImageGallery.cshtml", Model)
</div>
新的JavaScript在ImageGallery: -
<script type="text/javascript">
var pageTitle = $('#PageTitle').val();
var pageAction = $('#PageAction').val();
var id = $('#ArticleID').val();
$(document).ready(function () {
$('.modal_block').click(function (e) {
$('#tn_select').empty();
$('.modal_part').hide();
});
$('#modal_link').click(function (e) {
$('.modal_part').show();
var context = $('#tn_select').load('/Upload/UploadImage?Page=' + pageTitle + '&Action=' + pageAction + '&id=' + id, function () {
initSelect(context);
});
e.preventDefault();
return false;
});
});
</script>
现在这工作正常