我正在尝试在 asp.net mvc3 中使用 jquery。我正在使用 EditorTemplates 作为列表。我的模型是
public class staffinfo
{
    public int staffid { get; set; }
    public double extgrade { get; set; }
    public string lvlid { get; set; }
    public IList<SelectListItem> level { get; set; }
    public string grdid { get; set; }
    public IList<SelectListItem> grade { get; set; }
    public double pf { get; set; }       
    public double wages { get; set; }
    public List<hrfacility> facility { get; set; }
}
public class hrfacility
{
    public int id { get; set; }
    public string name { get; set; }
    public double price { get; set; }        
    public int staffid { get; set; }
    public string staffname { get; set; }               
    public double amount { get; set; }
    public bool selected { get; set; }
}
看法:
...
@Html.EditorFor(m => m.wages)    
@Html.EditorFor(m=>m.facility) 
hrfacility 的编辑器模板
@model Mysol.Models.hrfacility
...
@Html.DisplayFor(m=>m.name)
@Html.CheckBoxFor(m=>m.selected)    
@Html.EditorFor(m => m.staffname)
@Html.EditorFor(m => m.amount)
 <script type="text/javascript">
    $('#staffname').attr('readonly', true);
</script>
我在 editortemplates 中使用了没有列表部分的上述过程,并且 jquery 工作正常,但对于这种特殊情况,它不起作用!
是因为可能有不止一个员工姓名吗?
我怎样才能使 jquery 在上述情况下工作(使人员名称只读)?
PS readonly 仅用于示例目的。我还需要用 jquery 做其他事情,比如将值分配给文本框。如果我能得到这份工作,我想我也可以做其他事情。
谢谢