2011-02-14 2 views
0

안녕하세요, 저는 mvc 및 웹 개발에 새로운입니다. 이 같은 것을하고 싶습니다..net jvery가 포함 된 mvc load partialview

그런 다음 편집을 클릭하면 페이지가로드됩니다.

저는 이것을하기 위해 아약스를 사용하고 있습니다. 그러나 문제는 편집 할 때 아약스가 내 스크립트를 사용하지 않는다는 것입니다. 즉, 날짜 선택기 스크립트가 작동하지 않습니다. 또는 다른 자바 스크립트입니다.

<div id="Estudiantes del tutor"> 
      </br> 
      <table style="margin-left:auto; margin-right:auto;"> 
       <tr> 
        <th>Código</th> 
        <th>Estudiante</th> 
        <th></th> 
       </tr> 
       <% foreach (var item in Model.Hijos) { %> 
        <tr> 
         <td> 
          <%: Html.Encode(item.PersonaNaturalId.ToString("D8")) %> 
         </td> 
         <td> 
          <%: Html.Encode(item.Nombre +" "+item.ApellidoPaterno+ " "+ item.ApellidoMaterno) %> 
         </td> 
         <td> 
          <%: Html.ActionLink("Editar", "EditarEstudiante", new { tutorId = Model.TutorBE.PersonaNaturalId ,estudianteId = item.PersonaNaturalId }) %> 
           | 
          <%: Ajax.ActionLink("Editar", "EditarEstudiante", new { tutorId = Model.TutorBE.PersonaNaturalId ,estudianteId = item.PersonaNaturalId }, new AjaxOptions { UpdateTargetId = "DatosEstudiante"})%> 
         </td> 
        </tr> 
       <% } %> 
      </table> 
    </div> 
    <br/> 
    <br/> 
    <br/> 
    <div id="DatosEstudiante"> 

    </div> 

그리고처럼 내 부분도 보인다 :

미 코드는이

내 주요보기처럼

<link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> 
    <link href="../../Content/SiteHeinrich.css" rel="stylesheet" type="text/css" /> 
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script> 
    <script src="../../Scripts/jquery-ui-1.8.8.custom.min.js" type="text/javascript"></script> 
    <link href="../../Content/blitzer/jquery-ui-1.8.8.custom.css" rel="stylesheet" type="text/css" /> 
    <link href="../../Content/VocacionalSite.css" rel="stylesheet" type="text/css" /> 
    <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script> 
    <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script> 
    <script src="../../Scripts/MicrosoftMvcValidation.debug.js" type="text/javascript"></script> 

<br /> <%= Html.ValidationSummary("Por favor corrija los errores e intente de nuevo.")%> <%using (Html.BeginForm()) { %> <%: Html.ValidationSummary(true) %> <div id="DatosGenerales"> 
    <fieldset style="margin-left: auto; margin-right: auto;"> 
     <legend>Datos generales del estudiante</legend> 
     <div id="Nombres del estudiante"> 
      <div id="Nombre" style="float: left; margin-left: auto; margin-right: auto; width: 250px;"> 
       <%: Html.Label("Nombres: ") %> 
       <br /> 
       <%: Html.TextBox("Nombres", Model.Estudiante.Nombre, Model.Estudiante.Nombre != null ? new {@readonly ="readonly"} : null)%> 
       <%: Html.ValidationMessage("Nombres","*") %> 
      </div> 
      <div id="ApellidoPaterno" style="float: left; margin-left: auto; margin-right: auto; 
       width: 250px;"> 
       <%: Html.Label("Apellido paterno: ") %> 
       <br /> 
       <%: Html.TextBox("ApellidoPaterno", Model.Estudiante.ApellidoPaterno, Model.Estudiante.ApellidoPaterno != null ? new { @readonly = "readonly" } : null)%> 
       <%: Html.ValidationMessage("ApellidoPaterno","*")%> 
      </div> 
      <div id="ApellidoMaterno" style="float: left; margin-left: auto; margin-right: auto; 
       width: 250px;"> 
       <%: Html.Label("Apellido materno: ") %> 
       <br /> 
       <%: Html.TextBox("ApellidoMaterno", Model.Estudiante.ApellidoMaterno, Model.Estudiante.ApellidoMaterno != null ? new { @readonly = "readonly" } : null)%> 
       <%: Html.ValidationMessage("ApellidoMaterno", "*")%> 
      </div> 
     </div> 
     <br /> 
     <div id="Otros datos generales" style="clear: both;"> 
      <br /> 
      <script> 
       $(function() { 
        $("#datepicker").datepicker(); 
       });  </script> 



<div class="demo"> 

<p>Date: <input type="text" id="datepicker"></p> 

</div><!-- End demo --> 



<div class="demo-description" style="display: none; "> <p>The datepicker is tied to a standard form input field. Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay. Choose a date, click elsewhere on the page (blur the input), or hit the Esc key to close. If a date is chosen, feedback is shown as the input's value.</p> </div><!-- End demo-description --> 
     </div> 
    </fieldset> </div> 

답변

1

jQuery의 ready() 함수를 사용하여 스크립트를 실행할 것입니다.

그래서 당신의 부분보기

<script> 
$(function() 
{ 
    $("#datepicker").datepicker(); 
});  
</script> 

에서이 당겨 교장보기에 이것을 추가합니다. 페이지가로드 된 후에 실행됩니다.

<script type="text/javascript"> 
    $(document).ready(function() 
    { 
    $("#datepicker").datepicker(); 
    }); 
</script> 
0

jQuery의 document.ready는 한 번만 발생합니다. DOM이 준비된 후. 그래서 어떤 스크립트도 실행되지 않습니다. livequery과 같은 것을 사용하면됩니다.

관련 문제