asp.net mvc3에서 jquery를 사용하려고합니다. 목록에 EditorTemplates를 사용하고 있습니다. hrfacility에 대한jquery in editorfor
...
@Html.EditorFor(m => m.wages)
@Html.EditorFor(m=>m.facility)
EditorTemplate
@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와 잘 작동하지만에 대한 :보기
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; }
}
로 내 모델입니다 이 특별한 상황은 작동하지 않습니다 !!
staffname이 둘 이상있을 수 있습니까?
위의 상황에서 jquery를 어떻게 만들 수 있습니까? (staffname을 읽기 전용으로 만듭니 까?) ??
P. 읽기 전용은 예제 목적을위한 것입니다. 텍스트 상자에 값을 할당하는 것과 같은 jquery를 사용하여 다른 작업을 수행해야합니다. 이 일을 할 수 있다면 다른 일도 할 수 있다고 생각합니다.
감사
jquery에서 루프를 사용하여 필요한 텍스트 상자를 사용할 수 있습니까 ?? 그렇다면 어떻게? –
@ BJ.BJ : 물론 [.each()] (http://api.jquery.com/each/)를 사용하십시오. 그러나이 작업을 수행 할 필요는 없습니다. attr ('readonly', true)'만 실행하면됩니다. – Mohayemin