2013-10-16 3 views
6

제출하려는 양식이 있지만 제출 버튼을 클릭하면 양식이 계속 처리되거나 양식으로 취소 될 수있는 트위터 부트 스트랩 모달이 표시됩니다 페이지. 정규 자바 스크립트 확인을 부트 스트랩 모달로 돌릴 수 있습니까?부트 스트랩 모달을 사용하여 작업 확인

<form action="http://localhost.testing/modal-processing.php" class="form-horizontal" role="form" method="GET"> 
    <label>Landlord<span class="mandatory">*</span></label> 
    <select class="form-control input-sm chosen chzn-select" tabindex="1" data-placeholder="Choose a landlord" data-rule-required="true" name="landlord_id" id="landlord_id"> 
     <option value=""></option> 
     <option value="31" >Liam Lawlor</option> 
     <option value="34" >Damian Lavelle</option> 
     <option value="35" >Mick Lally</option> 
     <option value="36" >Joanne Lavelle</option> 
     <option value="37" >Liam Lacey</option> 
     <option value="38" >Laura Luney</option> 
     <option value="39" >Lenihan Enterprises</option> 
    </select> 

    <!-- modal caller --> 
    <a href="#modal-dialog" class="modal-toggle" data-toggle="modal" data-href="http://localhost.testing/modal-processing.php" data-modal-type="confirm" data-modal-title="Delete Property" data-modal-text="Are you sure you want to delete {$property.address_string}?" data-modal-confirm-url="{$base_url}residential-lettings/properties/do-delete/property/{$property.id}"><i class="icon-trash"></i> Modal Submit</a> 

    <!-- proper submit --> 
    <input type="submit"> 
</form> 

답변

10

당신은 링크/버튼을 활성화하여 확인으로 부트 스트랩 모달을 사용할 수 있습니다 (예 : 'btnYes') jQuery를 통해 양식 제출을 트리거하는 데 사용되는 모달에서 ...

$('#btnYes').click(function() { 
    // handle form processing here 
    $('form').submit(); 
}); 
여기

는 작업 데모입니다 : http://bootply.com/88094

+0

나를 위해 작동하지 않습니다. 양식이 Chrome에 제출되지 않았습니다. –

+0

Chrome에서 작동합니다. – ZimSystem

+0

매우 이상합니다. $ ('form')은 배열을 반환하므로 $ ('form') [0] .submit()이 작동합니다. 이것은 또한 작동합니다 : $ ('# myForm'). trigger ('submit'). 그러나 아아, 당신의 대답은 나를 위해 일하지 않습니다. –

0

당신에게 모달 버튼을 클릭 리스너를 추가 올바른 :

$('#myModalButton').click(function(){ 
    //submit form 
    // $('#myForm').submit(); // not working for me 
    // $('#myForm')[0].submit(); //works, but is ugly 
    $('#myForm').trigger('submit'); //works great 
}); 

내가 말할 수있는 한 $ ('form')은 배열을 반환합니다. 심지어 $ ('form # myForm')은 배열과 배열을 반환합니다.

그래서

,

$('form')[0].submit(); 

작동합니다.

$('#myForm').trigger('submit'); 

내가 작동하게하는 유일한 방법은?

관련 문제