I've been playing with Django Crispy Forms the last couple of days...It's working...Kinda...But now I'm running into a problem with the TinyMCE editor. I'm running django-tinymce 3.3.0. The TinyMCE field displays via the normal template, but when I run an ajax call to return the form via the render crispy form, it won't display. All of the other fields display via the django crispy forms view...but not the TinyMCE. I've been tracking two different errors in the console.
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/....
I found an article that says to set...
async: False...
On my AJAX call but it didn't help..
Uncaught TypeError: n.ui.isDisabled is not a function....
I've read a few articles that says this might be a plugin conflict...but can't find any issues here.
I'm running an AJAX call...
$.ajax({
method: 'post',
headers: { "X-CSRFToken": token },
url: "{% url 'Procedures:create_procedure' %}",
processData: false,
contentType: false,
cache: false,
data: formData,
enctype: 'multipart/form-data',
success: function (response) {
if (response.succes == true) {
$('#id_username').alert("Hello");
}
else {
$("#forms").replaceWith(response['form_html']);
}
},
});
});
My FORMS.py....
class Meta:
model = NewProcedure
exclude = [ 'created_by',]
procedure = forms.CharField(widget=TinyMCE(attrs={'cols': 50, 'rows': 30}))
def __init__(self, user, *args, **kwargs):
User = get_user_model()
super(CreateProcedureForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Div(
HTML("<h1 class='title62'>Create New Procedure</h1>"),
Field('procedure', forms.CharField(widget=TinyMCE(attrs={'cols': 50, 'rows': 30}))),
Submit('submit', 'Submit'),
)
)
I've also tried to add {{ form.media }} to my template but that doesn't help either. I can finally get the crispy forms to show the fields I'm trying to display...except for the TinyMCE field.
I've also tried...
{{ form.procedure|as_crispy_field }}
In the form...No dice.
I'm trying to render the fields individually...but just for fun I changed the template and tried both...
{% crispy form %}
{{ form|crispy }}
And these both render the form.....everything except for the TinyMCE field...the LABEL renders...but the field itself is not displaying on the form.