有没有办法(甚至没有使用部分视图)我可以更好地写这个,而不必为我的标签使用动态ID?我正在寻找比the best answer until now, hopefully
更新的东西public class Estates
{
public List<Addresses> Addresses { get; set; }
}
public class Addresses
{
...
...
public List<Phone> Phones { get; set; }
}
public class Phone
{
id..
num..
active..
}
HTML
@for (var index = 0; index < Model.Addresses.Count(); index++)
{
@html.partial(....)
}
部分视图 - 这是我的问题
@*Needed to replace div with ajax return html data*@
@*Otherwise Jquery doesn't know what field to update as it is rendered multiple times with the same id*@
<div id=@modelId>
...
ScriptFILE.js:(secondquestion?)令人遗憾的是,此时我将视图中的id发送到.js文件以运行...
$("#"+@modelId.ToString()).click(function(){ ... call some ajax... });