<html>
<body>
      <form id="preguntaForm" method="post" action="" class="form-horizontal ">
      <div class="modal-header">
        <button class="close" data-dismiss="modal">×</button>
        <h3>Nueva Pregunta</h3>
      </div>
      <div class="modal-body">
            {% csrf_token %}
              {% for field in form_pregunta%}
                  <div class="control-group">
                    <label class="control-label" for="input01" style="margin-right:10%;"><p><strong>{{ field.label}}</strong></p></label>
                    {% if  field.errors %}
                                  <div class="alert alert-error" style="margin-top:0.4em;width:10em;">
                                      <a class="close" data-dismiss="alert">×</a>
                                      <strong>ERROR</strong>{{ field.errors }}
                                  </div>
                                {%endif%}
                    <div class="controls">            
                      <p>{{field}}</p>
                    </div>
                  </div>
              {% endfor %}
      </div>  <!-- End body modal -->
      <div class="modal-footer">
        <a id="preguntaform-submit" class="btn btn-primary">Crear</a>
        <a href="#" class="btn" data-dismiss="modal">Cancelar</a>
      </div>
      </form>
</body>
</html>

{% block extra_js%}

<script src="{{MEDIA_URL}}js/bootstrap/jquery.js"></script>

<script type="text/javascript"> 
$(document).ready(function() {

  $('#preguntaform-submit').click(function(){
    alert($('#preguntaForm').serialize());
     //Envio por post
    $.ajax({
        type: 'POST',
        url: '{% url crear_pregunta_actividad_wizard actividad %}',
        data: $('#preguntaForm').serialize(),
        dataType: 'json',
        });
    $('[data-dismiss]="cancel"').click();

    return false; // poner a true para salir

  });
});

</script>
{% endblock %}

