2016-09-16 69 views
1

我有一个Django模式的小问题。莫塔尔不打开Django

我有一个链接,它调用一个id和id是一种模式。但是,模式不开放。我很肯定,这是因为链接是在“自动”的形式,但我是新的Django和Python,所以我不知道。

的代码是:

{% block body %} 
    <div class="col-lg-12 page-content"> 
     <h1 class="content-title">Meus Dados</h1> 
     <hr class="star-light"> 
     <div class="form-content"> 
      <form class="form-horizontal" method = 'POST' action="/user/edituser/"> 
       {% csrf_token %} 
       {% for field in form_user %} 
        {% bootstrap_field field exclude="password,repeat_password" %} 
       {% endfor %} 
       <div class="button-div"> 
        <a class="btn btn-info btn-block btn-password" href="#change-password" 
         data-toggle="modal">Alterar senha</a> 
        {% buttons %} 
         <button class="btn btn-success btn-block btn-edit" type = 'submit'>Salvar Dados</button> 
        {% endbuttons %} 
       </div> 
      </form> 
      <a class="btn btn-danger btn-block btn-delete" href="/user/delete" name="delete">Excluir minha conta</a> 
     </div> 
    </div> 
    <div class="modal hide" id="change-password"> 
     <div class="modal-header"> 
      <button class="close" data-dismiss="modal">&times;</button> 
      <p class="modal-title" id="myModalLabel">Change Password</p> 
     </div> 
     <div class="modal-body"> 
      <div class="row"> 
       <div class="modal-col col-sm-12"> 
        <div class="well"> 
         <form method="post" id="passwordForm"> 
          <input type="password" class="input-lg form-control" name="password1" 
           id="password1" placeholder="New Password"> 
          <input type="password" class="input-lg form-control" name="password2" 
           id="password2" placeholder="Repeat Password"> 
         </form> 
        </div> 
       </div> 
      </div> 
     </div> 
     <div class="modal-footer"> 
      <a href="#" class="btn btn-success btn-bloc">Alterar Senha</a> 
     </div> 
    </div> 
{% endblock %} 

任何疑问,请询问。 谢谢。

回答

0

褪色你<a>标签更改为以下:

<a class="btn btn-info btn-block btn-password" href="#" 
    data-toggle="modal" data-target="#change-password">Alterar senha</a> 

至少这是我在我的Django模板中做到的。我认为@souldeux想说,你需要使用data-target属性来指定模态本身,而不是href;在这种情况下,我通常只使用#

此外,请确保您不仅加载引导CSS代码,而且引导程序js库。换句话说,确保你在你的模板以下(或同等学历):

<!-- Latest compiled and minified JavaScript (at the time of this post) --> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 

除了你的CSS:

<!-- Latest compiled and minified CSS (at the time of this post) --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 

我假设你已经有了,否则事情会看起来很奇怪。

+0

遗憾的是仍然不能正常工作 –

+0

@ElaineCristinaMeirelles您是否在浏览器中看到任何错误(即在开发者控制台?)?此外,请确保您加载了引导程序js代码以及引导程序的css代码。 – elethan

+0

神圣的废话,我没有加载引导js代码,谢谢一百万。 –

0
<a class="btn btn-info btn-block btn-password" href="#change-password" data-toggle="modal">Alterar senha</a> 

你需要另外一个data-target属性您data-togglehttp://getbootstrap.com/javascript/#live-demo

+0

继续:no功能:/ –

+0

Desculpe,eusófaloinglês。查看该“启动演示模式”按钮的代码 - 尝试删除“href”属性,并确保数据目标与您的模式的ID相匹配,就像它在示例中所做的一样。请发布您在这里尝试的内容。 – souldeux

+0

我的不好,我说:仍然没有工作:/ –

0

尝试改变标签在

<a class="btn btn-info btn-block btn-password" href="#change-password" 
        data-toggle="modal">Alterar senha</a> 

“A” 标记 “按钮” 藏在

<div class="modal hide" id="change-password"> 
+0

不幸的是仍然不能正常工作 –