{% extends 'dashboard/dashboard_base.html' %}
{% block stage %}
<div class="content">
	<div class="new">
	 <div class="new-header">
	    <label>{% if badge %}Edit{% else %}New{% endif %} Badge</label>
	  </div>
	  <div class="new-user">
	    <form class="form-horizontal" role="form" name="categoryform" id="categoryform" method='post'>
	      <div class="form-group">
	        <label class="control-label col-sm-2" for="email">Title:</label>
	        <div class="col-sm-10">
	          <input type="text" class="form-control" id="title" name="title" placeholder="Enter Badge Title" value="{{badge.title}}">
	        </div>
	      </div>
	      <div class="form-group">
	        <div class="col-sm-offset-2 col-sm-10 save_buttons">
	          <button type="submit" class="btn btn-default submit">Submit</button>
	          <button type="button" class="btn btn-default cancel">Cancel</button>
	        </div>
	      </div>
	    </form>
	  </div>
	</div>
</div>
{% endblock %}
{% block extra_js %}
<script type="text/javascript">
$('form#categoryform').ajaxForm({
      type:'POST',
      dataType:'json',
      data:$('#categoryform').serialize(),
      success: function(data) {
        if (data.error == false) {
          alert(data.response);
          window.location = "{% url 'django_simple_forum:badges' %}";
        } else {
          $('div.error').remove();
          for (var key in data.response) {
            $('#' + key).after('<div class="error">' + data.response[key] + '</div>');
          }
        }
      }
    });
$('.cancel').click(function(e){
	window.location = "{% url 'django_simple_forum:badges' %}";
});

</script>
{% endblock %}