我有一段JavaScript代码,用于向用户显示确认对话框并传递变量以确认他们的操作。
请注意,我需要将以下JS确认代码转换为Twitter Bootstrap模态框代码:
然而,我必须将简单的确认对话框更改为 Twitter Bootstrap 模态框。
我尝试了几次,阅读了很多 SO 帖子和 Twitter Bootstrap 文档,但由于我的 JavaScript 知识不够好,我无法使其正常工作。我在在 Twitter Bootstrap 模态框中显示变量时遇到了问题。
希望有人能够通过给我一些指针来帮助我解决问题。
这是我当前的 js 对话框代码:
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\nIf you leave this option un-checked your saved '+ label +' will be deleted only after you update this page.\n\nAre you sure you want to delete your ' + count + ' saved ' + label +'?" %}')) {
checkbox.checked = true;
return;
}
}
$('#menu_entry_' + id).hide();
}
}
编辑:根据评论要求,添加了#menu_entry_的代码:
{% for id, menu_entry, selected, item_count in menu_entries %}
<li id="menu_entry_{{ id }}" {% if not selected %}style="display:none;"{% endif %}>
<a
{% if id == 4 %}
href="{% url summary_details %}"
{% elif id == 8 %}
href="{% url objective_details %}"
{% elif id == 12 %}
href="{% url leading_employment_details %}"
{% elif id == 16 %}
href="{% url desired_occupation_details %}"
....
{% elif id == 112 %}
href="/"
{% else %}
href="/"
{% endif %}
onclick="showProgressAnimation();">
请注意,我需要将以下JS确认代码转换为Twitter Bootstrap模态框代码:
if (! confirm('{% trans "You have '+ count +' saved '+ label +'.\n\nIf you leave this option un-checked your saved '+ label +' will be deleted only after you update this page.\n\nAre you sure you want to delete your ' + count + ' saved ' + label +'?" %}')) {
#menu_entry_*
的 HTML。 - cvrebert