【发布时间】:2017-11-28 15:42:27
【问题描述】:
我现在正面临 bootstrap-growl 插件问题显示,当我将两个按钮(它们触发通知)放在循环之外时,我可以清楚地看到我的两个通知,一切都按预期进行。所以从技术上讲,这个插件和循环之间存在一定的冲突。你有没有遇到过这个问题,即使两个按钮都在循环内,我怎么能得到我的通知?提前感谢您的帮助:)
这是我使用插件的部分:
<?php
$meinKommentare = controller_alleKommentareLesen();
if ($meinKommentare->rowCount() > 0) {
while ($row = $meinKommentare->fetch(PDO::FETCH_ASSOC)) {
extract($row);
?>
<tr>
<td><?php echo $kommentarDatum; ?></td>
<td><?php echo $benutzerName; ?></td>
<td></td>
<td><?php echo $kommentarInhalt; ?></td>
<td style="text-align: center">
<button id="bestaetigungButton" class="btn btn-success btn-xs" onclick="kommentarBestaetigen();"> <i class="fa fa-check fa-2x" ></i></button>
<button id="loeschungButton" class="btn btn-danger btn-xs" onclick="kommentarLoeschen();"> <i class="fa fa-trash-o fa-2x "></i></button>
</td>
</tr>
<?php
}
}
?>
这是我的 Javascript 代码:
<script>
$("#bestaetigungButton").click(function () {
$.bootstrapGrowl("another message, yay!", {
ele: 'body', // which element to append to
type: 'info', // (null, 'info', 'error', 'success')
offset: {from: 'top', amount: 20}, // 'top', or 'bottom'
align: 'right', // ('left', 'right', or 'center')
width: 250, // (integer, or 'auto')
delay: 4000,
allow_dismiss: true,
stackup_spacing: 10 // spacing between consecutively stacked growls.
});
});
</script>
PS:
当我在循环之外使用两个按钮时,我没有做任何改变 在我的代码中
【问题讨论】:
-
您的 php 正在生成 html。我们需要查看它生成的 html。查看浏览器中页面的 html 源代码with while 循环,然后without while 循环。在这两种情况下都发布相关部分的 html 源代码。
-
extract($row);非常糟糕的做法,特别是在全球范围内。
标签: javascript php css twitter-bootstrap bootstrap-notify