下拉列表使用ajax调用在部分视图中选择索引更改事件 [英] dropdown list selected index change event in partial view using ajax call
本文介绍了下拉列表使用ajax调用在部分视图中选择索引更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
冒险控制器:
if(itemVenture.VentureLocationID.Equals(itemLoc.VentureLocationID))
{
if(!_locationList_1.Contains(itemLoc))
_locationList_1.Add(itemLoc);
}
ViewBag.leftcontent1 = new SelectList(_locationList_1,VentureLocationID,VentureLocationName);
返回PartialView(_locationList_1);部分视图中
:
@model IEnumerable < Subhagruha.Model.VentureLocation >
@ Html.DropDownList(VentureLocation,新的SelectList(模型,VentureLocationID,VentureLocationName),项目 ,new {@id =VentureLocationID})
< script language = javascript type = text / javascript >
$(document).ready(function() {
$(#VentureLocation)。change(function(){
$ .ajax({
url:'@ Url.Action(Index,Venture)'+这个。 value,
data:{id:$('#VentureLocationID')。val()},
dataType:json,
type:get,
成功:功能(响应)
{}
});
});
});
< / script >
i我将风险投资地点放入下拉列表,但选择的指数变化并未触发,当我选择风险投资位置时,相应的风险投资位置应该转移到风险投资控制中的指数行动,任何人都可以回复我
解决方案
(document).ready(function(){
(#VentureLocation)。change(function() {
.ajax({
url:'@ Url.Action(Index,Venture)'+ this.value,
data:{id :
venture controller:
if (itemVenture.VentureLocationID.Equals(itemLoc.VentureLocationID))
{
if (!_locationList_1.Contains(itemLoc))
_locationList_1.Add(itemLoc);
}
ViewBag.leftcontent1 = new SelectList(_locationList_1, "VentureLocationID", "VentureLocationName");
return PartialView(_locationList_1);
in partial view:
@model IEnumerable<Subhagruha.Model.VentureLocation>
@Html.DropDownList("VentureLocation", new SelectList(Model, "VentureLocationID", "VentureLocationName"), "Projects", new { @id = "VentureLocationID" })
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#VentureLocation").change(function () {
$.ajax({
url: '@Url.Action("Index","Venture")' + this.value,
data: { id: $('#VentureLocationID').val() },
dataType: "json",
type: "Get",
success: function (response)
{ }
});
});
});
</script>
i am getting venture location in to dropdownlist but selected index change is not fireing and when i select a venturelocation corresponding venturelocationid should be passed to index action in venture controller can any one reply me pleasee
解决方案
(document).ready(function () {
("#VentureLocation").change(function () {
.ajax({ url: '@Url.Action("Index","Venture")' + this.value, data: { id:
这篇关于下拉列表使用ajax调用在部分视图中选择索引更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文