Hi, i am using a simple alert to see if i can
attach a click event to some dynamically created
input controls. so far without success...
can anyone see where i'm going wrong?
The page renders fine and behaves correctly except without the
click events.
thanks.
@model RM.Mobile.ViewModels.Attendance @{ ViewBag.Title = "Attendance List"; Layout = "~/Views/Shared/_Layout.cshtml"; } <h2> Your Class</h2> <script language="javascript" type="text/javascript"> $(document).ready(function () { $("div").each(function () { $("input", this).live("click", function () { alert("hi"); }); }); }); </script> @using (Html.BeginForm()) { <div> <strong>@Html.LabelFor(m => m.ClassDateText)</strong>: @Html.DisplayTextFor(m => m.ClassDateText) <br /> <strong>@Html.LabelFor(m => m.Description)</strong>:@Html.DisplayTextFor(m => m.Description) <br /> <strong>@Html.LabelFor(m => m.Teacher)</strong>: @Html.DisplayTextFor(m => m.Teacher) </div> <div data-role="fieldcontain" style="width: 85%"> <fieldset data-role="controlgroup" class="clickers"> @foreach (var item in Model.Results) { <label for='@item.TID' >@item.STUDENT_NAME</label> if (item.Present == true) { <input type="checkbox" name="@item.TID" id='@item.TID' value="true" checked="checked" /> } else { <input type="checkbox" name="@item.TID" id='@item.TID' value="true" /> } } </fieldset> </div> <p style="width: 85%"> <input id="btnSave" name="btnSave" type="submit" value="Save" /> </p> }