JQuery:通过悬停

时间:2016-10-08 07:06:57

标签: javascript jquery html asp.net-mvc

如何使div(<div id="HoverMe">)可以移动,并显示AllCarId - 列表中的名称列表(返回Car.Name代替Car.Id)?

  • 我有两张表Owner(Id)Car(Id, OwnerId, Name)
  • 我在ViewModel中有一个属性TotCar,我在控制器中使用Count()Car.OwnerId = Owner.Id中添加总model.TotCar
  • 我还在ViewModel中获得了public List<Guid> AllCarId { get; set; },以便将OwnerId传递给每个相关Owner.Id = Car.OwnerId的列表。

到目前为止,我得到了这个,我目前显示TotCar的计数值:

<div id="HoverMe">    
 @Html.DisplayFor(model => model.TotCar)  
</div>

@*I want this to be hoverable and list all from AllCarId(convert to name) in a "listbox"*@

那么我如何让<div id="HoverMe">可以悬停,一旦它悬停,就列出AllCarId中的每一项?

这就是我将id传递给控制器​​中AllCarId的方法。

List<Guid> GetCarIds = db.Cars.Where(c => c.OwnerId == id).Select(c=> c.OwnerId).ToList();

然后我将GetCarIds传递给模型public List<Guid> AllCarId { get; set; }属性。

编辑:模型的相关属性:

视图模型:

  public List<Guid> AllCarId { get; set; }
  public int TotCar { get; set; }       
  public virtual Car Car { get; set; }

汽车:

  public System.Guid Id { get; set; }
  public System.Guid OwnerId { get; set; }
  public string Name { get; set; }

拥有者:

public System.Guid Id { get; set; }

0 个答案:

没有答案