Alternative for Django-Tinymce-editor - django-tinymce

I used django-tinymce in my project. The django-tinymce editor is appended on textarea field using "tinyMCE.execCommand('mceAddControl', false, id); " command but the problem is that it does't have image upload functionality from local machine. please suggest me which editor suits in my condition.

Use jquery-easyui-1.3.4 example is below
<form id="my_form" action="/quiz/upload/" method="post" enctype="multipart/form-data">
{%csrf_token%}
<input id="image" name="image" type="file" /> <input type="submit" value="upload" />
and my script
<script type="text/javascript">
$(function(){ $('#my_form').form({ success:function(data){
tinymce.activeEditor.selection.setContent("<img src='"+data+"' />"); } });
});

Related

reCAPTCHA v3: g-recaptcha-response is outsite the form

With this example of reCAPTCHA v3, the g-recaptcha-response textarea is outsite the form...
<form method="post">
<input type="text" name="name" placeholder="Name">
<input type="text" name="email" placeholder="E-Mail">
<script type="text/javascript">
var onloadCallback = function() {
console.log('onloadCallback');
grecaptcha.execute(
"SITEKEY",
{action: "homepage"})
.then(function(token) {
console.log('verifyCallback')
console.log(token);
}
);
};
</script>
<script src="https://www.google.com/recaptcha/api.js?render=SITEKEY&onload=onloadCallback"></script>
<input type="submit" value="Send">
</form>
So there's no $_POST["g-recaptcha-response"]
What adjustments are necessary to provide the textarea inside the form tags?
You need the hidden input in your form that receives the response and you also need to set the token to the hidden input value
<input type="hidden" id="g-recaptcha-response" name="g-recaptcha-response" value="" />
document.getElementById('g-recaptcha-response').value = token;
However, I'm also having issues with the recaptcha v.3 implementation in Magento 2.

Database entry error

What's the problem in this code?
It shows no error while querying, neither does it get stored
<?php
if(isset($_POST['submit']))
{
$title=$_POST['title'];
$content=$_POST['content'];
$dbc=mysqli_connect('localhost','root','root','skype')
or die('Error connecting');
$query= "INSERT INTO pages (title,editor) VALUES ('$title', '$content')"
or die('Error querying database');
echo '<br>Page saved successfully under the title: '.$title.'<br>';
mysqli_close($dbc);
}
? >
<form>
<label for="title">Title</label>
<input type="text" name="title" required >
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
<textarea class="ckeditor" name="content" ></textarea>
<input type="submit" name="submit" value="Submit">
</form>
The default request method for a form is GET (see specs). If you want to POST your form you need to explicitly add the method:
<form method="post">
Otherwise your $_POST will always be empty.
Also, you are open to SQL injection.

AJAX form not returning data when using input file

im experiencing a weird issue. I have this form basically it just sends data to another cfm file that processes the inputs and updates a database. Today ive added an input type="file" so to process EXIF data from it and extract GPS info. The result page will copy a div to the specified target div. All works fine, data gets extracted and updated, but the div with the response does not appear anymore. As soon as i remove the input="file" div target div gets updated. Seems a response header issue, but i have no idea how to fix it. Thanks.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
$(document).ready(function() {
// bind form using ajaxForm
$('#sede-form').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#htmlExampleTarget',
// success identifies the function to invoke when the server response
// has been received; here we apply a fade-in effect to the new content
success: function() {
$('#htmlExampleTarget').fadeIn('slow');
}
});
});
</script>
<cfoutput query="dett_cli">
<form id="sede-form" enctype="multipart/form-data" action="modifica_sede_response.cfm" method="post" class="form-inline">
<input type="hidden" name="codice" value="#url.codice#" />
<input type="hidden" name="id_sede" value="#url.id_sede#" />
... [other fields]...
<input type="hidden" name="sed_coordinate_o" value="#sed_coordinate#" class="input-large">
<div class="control-group">
<label class="control-label" for="sed_coordinate">JPG Coordinate GPS </label>
<div class="controls">
<div class="input-prepend">
<input type="file" name="sed_coordinate" id="sed_coordinate" class="input-large">
</div>
</div>
</div>
... [other fields]...
<!-- END div.row-fluid -->
<div class="form-actions">
<button type="reset" class="btn btn-danger"><i class="icon-repeat"></i> Resetta</button>
<button type="submit" class="btn btn-success"><i class="icon-ok"></i> Aggiorna</button>
<div id="htmlExampleTarget"></div>
</div>
</form>
</cfoutput>
Try putting the following back into your ajaxForm options.
iframe:true,
forceSync:true,

CKEditor doesn't post data if I have an input type='file' in form

I am trying to use CKeditor plugin as HTML text editor. But the problem is if I have an input type="file" then when I submit the ckeditor plugin doesn't post the text I wrote inside it. But If I remove the input type="file" from my form then it works fine.
I need to have both in my form. Could you please tell me how to get both work fine?
Thanks
<script language="JavaScript" src="<?php echo base_url();?>support_admin/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
<form action="something">
<label>Details</label>
<textarea class="ckeditor" name="article" ><?php echo $articles; ?></textarea><br>
<label>Image 1</label>
<input type="file" name="imagefile1" /><br>
<button class="button" style="margin-left: 200px;">Submit</button>
</form>

jQuery won't send HTTP_X_REQUESTED_WITH header?

I have the following page, and checking the request, I can't find the HTTP_X_REQUESTED_WITH header? I even tried various hacks such as adding the header manually (per another question here), but to no avail. Anyone have any ideas?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#form").bind("submit", function(e) {
e.preventDefault()
$.post("/members/login/", $("#form").serialize(),
function(data){
alert(data);
});
});
});
});
</script>
<form id="form" action="" method="post">
<ul>
<li><label for="id_email">Email:</label> <input type="text" name="email" value="" id="id_email" /></li>
<li><label for="id_password">Password:</label> <input type="password" name="password" id="id_password" /></li>
</ul>
<input type="hidden" name="next" value="" />
<input id="submit" type="submit" value="" />
</form>
This shouldn't matter, but I use django and check with request.is_ajax(). I verified that the header isn't in the request. This is deployed on localhost.
There seems to be a closing too much in your code, try this:
<script type="text/javascript">
$(function() {
$("#form").on("submit", function(e) {
e.preventDefault()
$.post("/members/login/", $("#form").serialize(), function(data){
console.log(data);
});
});
});
</script>

Resources