I'm using CkEditor for Django and I have a form with 3 fields, a product code, a subject and a body. The first two fields are normal fields and the body field is a CKEditor field that is being rendered on the template from forms.py. In order to do an ajax call on this data, I need to use Jquery to get the CkEditor content. How to do this? This is my code so far.
My template:
form action="." method="post">
{{form2.as_p}}
{% csrf_token %}
<br><button name="form_submit" id="email_submit" type="submit" class="btn btn-primary" value="send_email">Submit</button>
</form>
My forms:
class CustomersWhoBoughtForm(forms.Form):
product_code = forms.CharField(required=True, max_length=1000, label='Product Code')
subject = forms.CharField(required=True, max_length=1000, label='Email Subject')
body = forms.CharField(widget=CKEditorUploadingWidget(config_name='default')) #trying to get value of this field for Ajax Call
I tried this:
var product_id= $('#id_product_code').val(); //This works
var subject = $('#id_subject').val(); //Also works
var body = $('#id_body').val(); //Does not work, neither does ck_id_body