我在父视图中有一个javascript函数说Check()
,这个父视图有一个名为child的局部视图。这个子视图中有一个java脚本函数,它将在锚标记点击后触发,然后调用我父视图的Check()
函数。
所以我需要从这个局部视图的函数中调用父视图的Check()
函数。 简单地将父视图的脚本函数放在部分视图中不会调用Check()
。我该怎么做,请在此纠正我
这是我到目前为止所做的,
我的部分视图脚本功能类似于
function supp_checkAndReset(elem) {
var currentSelected = $(elem).attr('id');
$('.supp_panelfilterresultholder span[title="' + currentSelected + '"]').remove();
$('.supp_panelfiltersuggestion input[value="' + currentSelected + '"]').prop('checked', false);
Check();
}
我的父视图脚本函数位于脚本标记下面,如
function Check() {
var supp_fullCheckList = $("#supp_filterWithThis").val();
var practice_fullCheckList = $("#practice_filterWithThis").val();
var county_fullCheckList = $("#county_filterWithThis").val();
var state_fullCheckList = $("#state_filterWithThis").val();
var ratebase_sliderValue = $("#ratebase_sliderValue").val();
var clientRating_sliderValue = $("#clientRating_sliderValue").val();
var panelRating_sliderValue = $("#panelRating_sliderValue").val();
$.ajax({
url: '@Url.Action("GetSearchResultBasedOnFilters", "SearchResult")',
type: 'GET',
data: {
supp_fullCheckList: supp_fullCheckList, practice_fullCheckList: practice_fullCheckList, county_fullCheckList: county_fullCheckList,
state_fullCheckList: state_fullCheckList, ratebase_sliderValue: ratebase_sliderValue, clientRating_sliderValue: clientRating_sliderValue, panelRating_sliderValue: panelRating_sliderValue
},
success: function (response) {
var totRecordCount = $('#RecordTotalCount').val();
$('#TotRecordCount').html(totRecordCount);
$('#searchArea').html('');
$('#searchArea').html(response);
},
error: function (xhr, status, error) {
alert(status + " : " + error);
}});
}
答案 0 :(得分:0)
我有同样的问题。将Java脚本函数supp_checkAndReset(elem)
和Check()
保留在主视图中,即在父视图中。因此可以从视图和局部视图访问它。
在父视图中应该是这样的。
<script type="text/javascript">
function supp_checkAndReset(elem) {
var currentSelected = $(elem).attr('id');
$('.supp_panelfilterresultholder span[title="' + currentSelected + '"]').remove();
$('.supp_panelfiltersuggestion input[value="' + currentSelected + '"]').prop('checked', false);
Check();
}
function Check() {
var supp_fullCheckList = $("#supp_filterWithThis").val();
var practice_fullCheckList = $("#practice_filterWithThis").val();
var county_fullCheckList = $("#county_filterWithThis").val();
var state_fullCheckList = $("#state_filterWithThis").val();
var ratebase_sliderValue = $("#ratebase_sliderValue").val();
var clientRating_sliderValue = $("#clientRating_sliderValue").val();
var panelRating_sliderValue = $("#panelRating_sliderValue").val();
$.ajax({
url: '@Url.Action("GetSearchResultBasedOnFilters", "SearchResult")',
type: 'GET',
data: {
supp_fullCheckList: supp_fullCheckList, practice_fullCheckList: practice_fullCheckList, county_fullCheckList: county_fullCheckList,
state_fullCheckList: state_fullCheckList, ratebase_sliderValue: ratebase_sliderValue, clientRating_sliderValue: clientRating_sliderValue, panelRating_sliderValue: panelRating_sliderValue
},
success: function (response) {
var totRecordCount = $('#RecordTotalCount').val();
$('#TotRecordCount').html(totRecordCount);
$('#searchArea').html('');
$('#searchArea').html(response);
},
error: function (xhr, status, error) {
alert(status + " : " + error);
}});
}