2016-06-09 3 views
1

누군가가 다음 문제로 나를 도울 수 있기를 바랍니다. 여러 체크 박스가있는 모달 안에 폼이 있습니다.MaterializeCSS - ASP. 닷넷 MVC : 모달의 체크 박스

cshtml은 다음과 같습니다 @Html.Checkbox으로

<div id="modal1" class="modal"> 
    <div class="modal-content"> 
     <form> 
      <p> 
       @Html.CheckboxFor(x => x.CheckValue, new {@type = checkbox}) 
       @Html.LabelFor(x => x.CheckValue) 
      </p> 
     </form>  
    </div> 
</div> 

내가 부모의 바닥에 숨겨진 요소를 이동하는 this 스크립트를 사용하여 숨겨진 입력 요소를 작성합니다.

$(document).ready(function() { 
    $('input:hidden').each(function (index, element) { 
     $(element).appendTo($(element).parent()); 
    }); 
}); 

그러나 확인란을 모달 내부에있을 때 나는이 HTML 얻을 : 내가 얻을 것 모달의

<div> 
    <label for="CheckValue">CheckValue:</label> 
    <input id="CheckValue" name="CheckValue" type="checkbox" value="true"> 
    <input id="CheckValue" type="hidden" value="false" > 
    ::after:: 
</div> 

외부 (이 작품 확인란을 모달 내부가 아닌 경우 스크립트는 완벽하게 작동) :

<div> 
    <input id="CheckValue" name="CheckValue" type="checkbox" value="true"> 
    <label for="CheckValue">CheckValue:</label>  
    <input id="CheckValue" type="hidden" value="false" > 
</div> 

어떻게 든 레이블이 맨 위로 밀려납니다. 모달의 입력 사이에 레이블을 수동으로 (개발자 도구에서) 이동하면 확인란을 볼 수 있지만 클릭 할 수는 없습니다. 누군가 나를 도와 줄 수 있습니까? 다른 사람이 문제로 실행 그냥 경우

답변

2

는 - 여기 내 솔루션입니다 : 모달 열을 위해 내가 콜백 함수에서 이것을 사용

$('.modal-trigger').leanModal({ 
     ready: function() { 
       //moves the hidden input to the bottom of the parent element 
       $('input:hidden').each(function (index, element) { 
        $(element).appendTo($(element).parent()); 
       }); 
     } // Callback for Modal open 
});