【发布时间】:2020-08-13 04:14:55
【问题描述】:
我正在使用带有逻辑的 PHP 构建应用程序,
- 打开两个文件。
- 一个文件值显示菜单,回显到浏览器中。
- 如果我们点击任何菜单,需要打开一个模态框,其值包含第二个文件。
我只是用 while 循环迭代。 问题是... 第一个文件中的菜单正在回显。但是,该模式仅适用于最后一个菜单。
当我检查时,会创建菜单和模式。 https://postimg.cc/crQ8JCr5 - 检查截图
$myfile1 = fopen("fisrt-file.dat", "r") or die("Unable to open file!");
$myfile2 = fopen("Second-file.dat", "r") or die("Unable to open file!");
while(!feof($myfile1)) {
$fistFile = fgets($myfile1);
$seconfFile = fgets($myfile2);
echo "<div class='one-by-three1'><div class='course-card1' data-toggle='modal' data-target='#".$seconfFile."'><p class='e-c-head'>".$fistFile."</p></div></div>";
echo "<div class='modal fade' id='".$seconfFile."' tabindex='-1' role='dialog' aria-labelledby='exampleModalCenterTitle' aria-hidden='true'>
<div class='modal-dialog modal-dialog-centered' role='document'>
<div class='modal-content'>
<div class='modal-header'>
<h5 class='modal-title' id='exampleModalLongTitle'>".$fistFile."</h5>
<button type='button' class='close' data-dismiss='modal' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>
<div class='modal-body'>
<p>Second file element</p>
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-secondary' data-dismiss='modal'>Close</button>
</div>
</div>
</div>
</div>";
}
fclose($myfile1);
fclose($myfile2);
我使用了引导模式。 菜单将数据目标作为第二个文件值传递。
【问题讨论】:
-
从 UI 的角度来看:您不想向用户猛烈抨击两种模式。您可以考虑使用手风琴或带有内容开关的模式。据我所知,引导程序中的模态不会按照您期望的方式工作。
-
@maio290 非常感谢。我只是用手风琴做到了。
标签: php html server modal-dialog