2016-09-29 11 views
0

私はDjangoを使用していますが、私はモーダルでデータを送信して要素の情報を取得しようとしています。データをモーダルに送信

<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#informations"> 
    <span class="glyphicon glyphicon-trash" aria-hidden="true">{{registration_id}}</span> 
</button> 

モーダルはオープン正しくモーダル

<div class="modal fade" tabindex="-1" role="dialog" id="information"> 
    <div class="modal-dialog" role="document"> 
     <div class="modal-content"> 
      <div class="modal-body"> 
       <form method="post" action="{% url 'informations_choices' %}"> 
        {% csrf_token %} 
        <input type="hidden" name="registration" value=......> 
        Get info about : ...... 
       </form> 
      </div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-primary" onclick="$('#information').modal('hide');$('#informations_choices').submit()"> 
        Get Info 
       </button> 
      </div> 
     </div> 
    </div> 
</div> 

ですが、どのように「......」値に変換することができます:モーダルを開くために

私のボタンがあります(ボタンに存在するとexemple {{REGISTRATION_ID}}で?事前に

おかげ

答えて

0

私はモーダルは最初から同じページにあるとここでは思っています。 ....{{registration_id}}に置き換えることができます。 ....をダイナミックにして、その人がページにいる間に変更したい場合は、JavaScriptフレームワークを調べて、AJAXリクエストを処理したいと思うかもしれません。

あなたはプレーンなAJAXと一緒に行きたい場合は、このようなものに終わるだろう:

$.ajax({ 
    type: "POST", 
    url: "/getnewvalue/", 
    data: { array : items_array }, 
    success: function (data) {  
    // make the changes to the DOM. 
    }, 
    error: function(data) { 
     $("#MESSAGE-DIV").html("Something went wrong!"); 
    } 
}); 
+0

私はそれについて考えていない、なぜああ、それは....単にそうだに^^ – Meojifo

関連する問題