为什么下面的代码不显示模态?
按钮:
<td><button type="button" id="display" class="btn btn-warning btn-small">Yes »</button> </td>
Javascript:
<script type="text/javascript">
$('#display').click(function(e)
{
var displaydatasharingModal = $('#displaydatasharingModal')
var emails = <?php echo json_encode($emails) ?>;
//var current_id = $(this).data('id');
//$(".modal-body #current_id").val(current_id);
console.log(emails);
alert("yes!");
// function to get the options
function getPropsAsString(emails) {
var props = [];
for (prop in emails) {
var val = emails[prop];
// Filter out blank at beginning and "Add New"
//if (val === " " || val === "Add New")
// continue; // skip it
props.push(prop);
}
// Sort them (what the hell)
props.sort();
return props.join(", ");
}
$('#modal-body span2').html(getPropsAsString(emails));
displaydatasharingModal.modal('show');
}
</script>
模态:
<!-- modal (Display Data Sharing) -->
<div class="modal small hide fade" id="displaydatasharingModal" tabindex="-1" role="dialog" aria-labelledby="displaydatasharingModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="displaydatasharingModalLabel">Data shared with:</h3>
</div>
<div class="modal-body">
<p> Current access emails are: <p><span2></span2></p></p>
<p>some content</p>
<input type="text" name="current_id" id="current_id" value=""/>
</div>
<div class="modal-footer">
</div>
</div>
我知道我的模态中有很多奇怪的东西,我希望很快就能解决。但我认为我的问题非常基本。为什么单击按钮时没有出现模态框?!我这样做与一些以前编写的代码作品平行。为什么它在这种情况下不起作用令人费解。有一段时间我一直在扯这个头发。帮助我的天才!