In my view I have the following code which is loaded with properties from an object, which display just fine when I run my project.. But, how can I access the properties of that object in Jquery? Currently what I am getting from the console.logs is undefined.
Edit: I tried adding @Html.Raw(Json.Encode(Model) to my view and I can now see every prop of the object when I hit inspect in the html, but I still can´t access em in jquery.
function EditTrabajoEnColegio(li) {
console.log(li); //this displays the entire li in the console.
//From here, I get all as undefined
console.log(this.TrabajoId);
console.log(li.contrato);
console.log(li.mesIngreso);
console.log(li.anioIngreso);
console.log(li.esTitular);
console.log(li.cargoColegio);
console.log(li.sueldoBruto);
}
<li id="li-@Model.TrabajoId" class="list-group-item"
onclick="EditTrabajoEnColegio(this)">
@Model.MesIngresoStJohns/@Model.AnioIngresoStJohns
-
@(Model.AnioEgresoStJohns != null ?
Model.MesEgresoStJohns.ToString() + "/" +
Model.AnioEgresoStJohns.ToString() : "Actualidad")
-
@Model.SedeNombre
Model.TipoDocenteId
Model.TieneContrato
@Model.CargoColegio
@Html.HiddenFor(x => x.TrabajoId)
@Html.HiddenFor(x => x.SedeId)
@Html.HiddenFor(x => x.AnioEgresoStJohns)
@Html.HiddenFor(x => x.AnioIngresoStJohns)
@Html.HiddenFor(x => x.MesIngresoStJohns)
@Html.HiddenFor(x => x.MesEgresoStJohns)
@Html.HiddenFor(x => x.FechaIngreso)
@Html.HiddenFor(x => x.FechaEgreso)
@Html.HiddenFor(x => x.SedeNombre)
@Html.HiddenFor(x => x.CargoColegio)
@Html.HiddenFor(x => x.TipoDocenteId)
@Html.HiddenFor(x => x.EsTitular)
@Html.HiddenFor(x => x.TieneContrato)
@Html.HiddenFor(x => x.SueldoBruto)
</li>
}
Any help will be apreciated.