Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 烧瓶未在回路中工作的确认模式_Python_Flask_Jinja2 - Fatal编程技术网

Python 烧瓶未在回路中工作的确认模式

Python 烧瓶未在回路中工作的确认模式,python,flask,jinja2,Python,Flask,Jinja2,我的程序列出了一组可以删除的用户。一旦删除,在删除用户之前会有一个确认模式 代码的删除部分可以工作,但我对模式本身有问题,因为它是在deleting users函数中传递数据的部分 我的html循环用户及其角色集。不要介意角色,因为我只关心确认模式。:) 例如: x用户1 x用户2 x user3(这是我要删除的一个) 当我删除user3时,它会删除user1。结果是: x用户2 x用户3 这是我的HTML代码。模态已经包括在内 <div class="col-md-10">

我的程序列出了一组可以删除的用户。一旦删除,在删除用户之前会有一个确认模式

代码的删除部分可以工作,但我对模式本身有问题,因为它是在deleting users函数中传递数据的部分

我的html循环用户及其角色集。不要介意角色,因为我只关心确认模式。:)

例如:

x用户1
x用户2
x user3(这是我要删除的一个)

当我删除user3时,它会删除user1。结果是:

x用户2
x用户3

这是我的HTML代码。模态已经包括在内

<div class="col-md-10">


            {% for u in all_users %}

              <td>
              <a href="#" data-toggle="modal" data-target="#confirm-delete"><img src = "{{url_for('static', filename='assets/images/x.png') }}"></a> 
              <!-- <a href="{{url_for('Users.delete_users', user=u.username)}}" " ><img src = "{{url_for('static', filename='assets/images/check.png') }}"></a> -->
              {{u.username}}
              </td>


              {% for r in roles %}
                <td><input type="checkbox" name="{{u.username}} {{r.name}}" value="{{r.name}}" 
                {% if r in u.load_roles(u.username) %}
                checked
                {% endif %}
                /></td> 
              {% endfor %}
              </tr>

              {% for u in all_users %}
              <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">

                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">Confirm Selection</h4>
                        </div>

                        <div class="modal-body">
                            <p>Do you want to proceed?</p>
                            <p class="debug-url"></p>
                        </div>

                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                            <a href="{{url_for('Users.delete_users', user=u.username)}}" class="btn btn-danger" name="button">Proceed</a>
                        </div>

                    </div>
                </div>
            </div>
            {% endfor %}

            {% endfor %}

            <input class="btn btn-primary" button type="submit" name="button" value="Save Roles"></input><br>
        </form>
            </tbody>
          </table>

{所有_用户%中u的百分比}
{{u.username}
{角色%r中的%r}
{%endfor%}
{所有_用户%中u的百分比}
&时代;
确认选择
你想继续吗

取消 {%endfor%} {%endfor%}

有两个问题。第一个问题是为每个用户创建一组模态。通过用户将
{%endfor%}
标记之一向上移动到第一个循环下

其次,对每个模式重用
id
属性<代码>ids必须是唯一的。你应该使用类似于

<a href="#" data-toggle="modal" data-target="#confirm-delete-{{ u.id }}"><img src = "{{url_for('static', filename='assets/images/x.png') }}"></a> 

在用户的第一个循环中,然后

<div class="modal fade" id="confirm-delete{{ u.id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">


在第二个

你能添加查看功能吗?顺便说一下,您不能将div用作或的子级。在内部使用div是可以的。你有一些结束标记(,),我找不到它们的开始标记。