Commit 92e9d87c by Matthew Mongeau

wip

parent 45f516cd
......@@ -4,26 +4,35 @@
ajax: function(options) {
return $.ajax(options);
},
fire: function(obj, name, data) {
var event = $.Event(name);
obj.trigger(event, data);
return event.result !== false;
},
handleRemote: function(element) {
var method = element.attr('method');
var url = element.attr('action');
var data = element.serializeArray();
var options = {
type: method || 'GET',
data: data,
dataType: 'text json',
success: function(data, status, xhr) {
element.trigger("ajax:success", [data, status, xhr]);
},
complete: function(xhr, status) {
element.trigger("ajax:complete", [xhr, status]);
},
error: function(xhr, status, error) {
element.trigger("ajax:error", [xhr, status, error]);
if(this.fire(element, "ajax:before")) {
var method = element.attr('method');
var url = element.attr('action');
var data = element.serializeArray();
var options = {
type: method || 'GET',
data: data,
dataType: 'text json',
success: function(data, status, xhr) {
element.trigger("ajax:success", [data, status, xhr]);
},
complete: function(xhr, status) {
element.trigger("ajax:complete", [xhr, status]);
},
error: function(xhr, status, error) {
element.trigger("ajax:error", [xhr, status, error]);
}
}
if(url) { options.url = url; }
return form_ext.ajax(options)
} else {
return false;
}
if(url) { options.url = url; }
return form_ext.ajax(options)
},
CSRFProtection: function(xhr) {
var token = $.cookie('csrftoken');
......
......@@ -118,8 +118,18 @@
</div>
</section>
<script src="${static.url('js/jQuery.validity.min.js')}"></script>
<script type="text/javascript">
(function() {
$(document).delegate('#register_form', 'ajax:before', function() {
var username = $("input[name=username]").value();
console.log(username)
return false;
});
$(document).delegate('#register_form', 'ajax:success', function(data, json, xhr) {
if(json.success) {
location.href="${reverse('dashboard')}";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment