Hello
We load a form with a ajax post command. When the form is loaded and the page is reloaded with f5 the ajax.py methods are registred twice in the generic java script:
var Dajaxice = {
portal: {
ajax_load_home: function(callback_function, argv, custom_settings){
Dajaxice.call('portal.ajax_load_home', callback_function, argv, custom_settings);
}
contact: {
Uncaught SyntaxError: Unexpected identifier // Added by google chrome dev view
ajax_load_contact_form: function(callback_function, argv, custom_settings){
Dajaxice.call('portal.contact.ajax_load_contact_form', callback_function, argv, custom_settings);
},
ajax_save_contact_form: function(callback_function, argv, custom_settings){
Dajaxice.call('portal.contact.ajax_save_contact_form', callback_function, argv, custom_settings);
},
send_form: function(callback_function, argv, custom_settings){
Dajaxice.call('portal.contact.send_form', callback_function, argv, custom_settings);
}
}
},
contact: {
ajax_load_contact_form: function(callback_function, argv, custom_settings){
Dajaxice.call('contact.ajax_load_contact_form', callback_function, argv, custom_settings);
},
ajax_save_contact_form: function(callback_function, argv, custom_settings){
Dajaxice.call('contact.ajax_save_contact_form', callback_function, argv, custom_settings);
},
send_form: function(callback_function, argv, custom_settings){
Dajaxice.call('contact.send_form', callback_function, argv, custom_settings);
}
}
ajax.py of the form:
from dajax.core import Dajax
from dajaxice.core import dajaxice_functions
from portal.contact import views
from django.views.decorators.csrf import csrf_exempt
from forms import ContactForm
from django.middleware.csrf import get_token
def ajax_load_contact_form(request):
get_token(request)
dajax = Dajax()
dajax.assign('#contentText','innerHTML',views.post_contact(request))
return dajax.json()
def ajax_save_contact_form(request):
get_token(request)
dajax = Dajax()
dajax.assign('#contentText','innerHTML',views.save_contact(request))
return dajax.json()
@csrf_exempt
def send_form(request, form):
dajax = Dajax()
form = ContactForm(form)
dajax.assign('#contentText','innerHTML',views.save_contact(form))
return dajax.json()
dajaxice_functions.register(ajax_load_contact_form)
dajaxice_functions.register(ajax_save_contact_form)
dajaxice_functions.register(send_form)
Is there something wrong in the code or a bug? I can't see it.
Thanks