我在控制器中遇到问题,我在集合中设置值并将它们存储在 ViewData 中。例如:
ViewData["ex1"] = new SelectList(ex1); // a simple collection
ViewData["ex2"] = new SelectList(group.Members, "Id", "Gender");
我将这些传递给我的视图并像这样循环。例如:
<div id="divListBox" style="overflow:auto; border:1px solid #CCCCCC; padding-left:5px; background-color:white; height: 130px">
<%
var list = this.ViewData["e2x"] as SelectList;
var pList = this.ViewData["ex1"] as SelectList;
foreach (var p in list)
{
foreach (var pil in pList)
{
if(pil.Text.Contains(p.Value)) // ex1 does contains ex2
{
%>
<input id="cbPerson" type="checkbox" value="<%= p.Value %>" />
<label for="cbPerson"><%= p.Text %></label>
<input id="cbPersonInfo" type="hidden" value="<%= pil.Text %>" /><br />
<%
}
}
}
%>
</div> ...
这是我的 jQuery。例如:
$('#divListBox > input').each(function() {
var personInfo = $('#cbPersonInfo').val();
$(this).append($('personInfo'));
$('*').qtip('hide');
$('#divListBox label').each(function() {
$(this).qtip({
content: personInfo,
show: 'mouseover',
hide: 'mouseout',
style: {
classes: 'ui-tooltip-custom',
tip: true
},
position: {
my: 'left bottom',
at: 'top right'
}
});
});
});
如果我将“隐藏”的输入类型设置为“文本”,我会看到每个输入类型的正确信息。但是,当我将鼠标悬停在它们上时,第一个信息显示为所有它们的工具提示。我认为这可能是我的 jquery,但我不太确定。我已经处理这个问题几个小时了,但仍然一无所获。有人可以帮忙吗?