동적으로 확인란을 선택 취소하고 동적으로 숨기거나 폼에 나타나는 목록의 일부인 menu_entry를 표시하는 자바 스크립트 확인/취소 팝업 상자가 있습니다. 확인 버튼이 js 팝업 상자를 확인합니다.부트 스트랩 모달에 변수를 전달합니다.
지금 js confirm을 부트 스트랩 모달로 변경하려고합니다.하지만 부트 스트랩 모달 코드에 변수를 전달하고 js confirm 팝업 상자의 동일한 기능을 얻는 방법을 잘 모릅니다.
다음{% for id, menu_entry, selected, item_count in menu_entries %}
<div class="available_resume_details_height">
<input type="checkbox"
style="width:1.5em; height:1.5em;"
name="selected_items"
value="{{ id }}"
{% if selected %}checked="checked"{% endif %}
onclick="checkboxUpdated(this, {{ item_count }}, '{{ menu_entry.label }}', {{ id }});"
/>
<span style="cursor: pointer;"
rel="popover"
data-content="{{ menu_entry.tooltip }}"
data-original-title="{{ menu_entry.label }}"
{{ menu_entry.label }}
</span>
</div>
{% endfor %}
목록을 숨길/확인 팝업을 표시하고 체크 박스와 쇼를 취소하는 내 자바 스크립트 코드 : 여기
상자를 팝업 확인 자바 스크립트 호출을 가지고 내 작업 html 코드입니다 항목 :function checkboxUpdated(checkbox, count, label, id) {
if (checkbox.checked) {
$('#menu_entry_' + id).show();
} else {
if (count > 0) {
if (! confirm('{% trans "You have '+ count +' saved '+ label +'.\n\nAre you sure you want to delete your ' + count + ' saved ' + label +'?" %}')) {
checkbox.checked = true;
return;
}
}
$('#menu_entry_' + id).hide();
}
}
다음은 부트 스트랩 모달을 호출하는 새로운 html 코드입니다. 그러면 부트 스트랩 모달이 나타납니다.
{% for id, menu_entry, selected, item_count in menu_entries %}
<div class="available_resume_details_height">
<input type="checkbox"
style="width:1.5em; height:1.5em;"
name="selected_items"
value="{{ id }}"
{% if selected %}checked="checked"{% endif %}
{% if selected %}
data-confirm="{% blocktrans with entry_label=menu_entry.label %}Are you sure you want to remove your {{ item_count }} selected {{entry_label}} Resume Details?{% endblocktrans %}"
{% endif %}
/>
<span style="cursor: pointer;"
rel="popover"
data-content="{{ menu_entry.tooltip }}"
data-original-title="{{ menu_entry.label }}"
{{ menu_entry.label }}
</span>
</div>
{% endfor %}
다음은 작동하지 않는 부트 스트랩 모달 코드입니다. 나는 변수를 전달하고, JS의 동일한 기능을하는 방법을 확실하지 오전 확인 팝업 :
$(document).ready(function() {
$('input[data-confirm]').click(function(ev) {
var href = $(this).attr('href');
if (!$('#dataConfirmModal').length) {
$('body').append('<div id="dataConfirmModal" class="modal modal-confirm-max-width" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true"><icon class="icon-remove"></icon></button><h4 class="modal-title" id="dataConfirmLabel">{% trans "Confirm" %} - {{ resume_detail_temp_value }}</h4></div><div class="modal-body"></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">{% trans "Cancel" %}</button> <a class="btn-u btn-u-blue" id="dataConfirmOK">{% trans "Confirm" %}</a></div></div>');
}
$('#dataConfirmModal').find('.modal-body').html($(this).attr('data-confirm'));
$('#dataConfirmModal').modal({show:true});
$('#dataConfirmOK').click(function() {
// handle checkbox function here.
});
return false;
});
});
부트 스트랩 모달/목록 항목을 숨기고 확인 버튼을 선택한 경우에만 체크 박스를 체크 해제 표시되어야합니다.
편집 : ADDED 체크 박스 CODE :
<input type="checkbox"
style="width:1.5em; height:1.5em;"
name="selected_items"
value="{{ id }}"
{% if selected %}checked="checked"{% endif %}
onclick="checkboxUpdated(this, {{ item_count }}, '{{ menu_entry.label }}', {{ id }});"/>
을 참조하십시오. 이것은 매우 도움이되었습니다. – user1261774
위대한 !! 도움이 되셨다면 다행입니다. 즐겨! – PeterKA