Comments (16)
I solved the problem by using this formula:
$(document).ready(function(){
var editor = $("#txtEditor").Editor();
$("button:submit").click(function(){
$('#txtEditorContent').text($('#txtEditor').Editor("getText"));
});
<?php
if($my_var){
?>
$('#txtEditor').Editor("setText", "<?php echo addslashes($my_var);?>");
<?php
}
?>
});
from line-control.
As I mentioned earlier, I would rather use json_encode
instead of addslashes
because it will encode the PHP object (string in this case) to JavaScript-safe characters. So, if $my_var
has newlines, they will be converted to \n
(as opposed to addslashes
who will leave them as-is and break JavaScript).
Only note that json_encode
puts quotes around the output string, so the line:
$('#txtEditor').Editor("setText", "<?php echo addslashes($my_var);?>");
Should be changed to:
$('#txtEditor').Editor("setText", <?php echo json_encode($my_var);?>);
(Note lack of quotes around <?php ... ?>
)
from line-control.
Take the quotes out of PHP, into Javascript:
$("#txtTip").Editor("setText", "<?php echo $dbText; ?>");
In fact, it is better to also use addslashes()
if quotes in $dbText
are not escaped.
from line-control.
$("#txtTip").Editor("setText", "");
Worked " in part " ... with more complex texts from BD, gives the error:
"Uncaught SyntaxError: Unexpected token ILLEGAL "
I had to do so :
< di v id="descricaoHTML" style='display:none'></ di v>
Calling the editor:
$("#txtTip").Editor();
$('.Editor-editor').html($("#textHTML").html()); // Loads the HTML contents from #textHTML into Editor
Only then it worked 100 %.
Thanks.
from line-control.
"Uncaught SyntaxError: Unexpected token ILLEGAL "
Which character(s) trigger that error?
If you can't see any strange character, maybe it is something related to some invisible Unicode character?
from line-control.
How can i load a default value. i can save neither can i load a default value from my database.
it keep giving me error here:
getText: function(){
//Function to get the source code.
if(!$(this).data("source-mode"))
return $(this).data("editor").html();
else
return $(this).data("editor").children().first().text();
},
pointing to the error here----> return $(this).data("editor").html();
what am i not doing right?
from line-control.
I was experiencing the same issues and it turned out to be line breaks in the html I was storing in my database. After using addslashes($dbText), I replaced the line breaks and this fixed it for me.
$dbText= preg_replace('/\r\n|\r|\n/', " ", $dbText);
from line-control.
If you are using PHP >= 5.2 then you can use json_encode
to escape all Javascript "problematic" characters:
$dbText = json_encode($dbText);
addslashes
does not escape newlines, as I thought earlier... 😞
from line-control.
My aplication php use de Line-control, I can save the data in Mysql but I can not show the data in Line-control. I try use this
$(document).ready(function(){
$("#txtEditor").Editor("setTxt","<?php echo $data;?>");
});
But can not work.
Please help.
from line-control.
I'm having the same problem :(
from line-control.
Great Job @mouraleonardo !! You save my time. Thanks!
from line-control.
I think you meant #txtEditor
(and not #txtEditorContent
) in the line 4?
$('#txtEditorContent').text($('#txtEditor').Editor("getText"));
from line-control.
i had this problem finally this worked for me :
i save this value in a longText field in database
$(".Editor-editor").html();
when retrieving data from database
$(".Editor-editor").append();
from line-control.
Dear @xOneca ,
I have solved the problem using $('#txtEditor').Editor("setText", <?php echo json_encode($my_var);?>);
as you mentioned (#issuecomment-125538718).
I can paste text with format into the Editor and it saves it correctly in the database.
However, when I want to edit it (using the code mentioned) the Editor changes the information taken from the database.
For example, if I paste "Text" in italics with yellow highlight, it is saved correctly in the database. And if I call the cell in the database to execute in HTML, it shows it correctly ("Text" in italics with yellow highlight).
When I come back to the Editor to edit this information, the function "setText" is not working perfectly as the text that is set is "Text" in italics WITHOUT yellow highlight. And then, if I saved this edition, it's saved in the database without yellow highlight.
This is just an example of how it looses information. I don't know why or how to solve it.
Thank you very much in advance.
from line-control.
Hello,
I'm sorry I do not know english
I can send the message with the following code, No problem
echo $_POST['message'];
`
<textarea id="txtEditor" name="txtEditor"></textarea>
<textarea id="message" name="message" hidden=""></textarea>
<script language="javascript" type="text/javascript">
$(document).ready( function() {
$("#txtEditor").Editor();
$("input:submit").click(function(){
$('#message').text($('#txtEditor').Editor("getText"));
});
});
</script>
</div>
`
1 is Is. the code above correct?
2 nd. How do I get into the editor to edit the message?
I don't know Javascript at all. php know very very little
Can you help me
Thank you in advance
from line-control.
Submit with PHP and AJAX and write to database and editing again
Works perfectly
https://stackoverflow.com/questions/58019169/post-wysiwyg-text-editor/58030972#58030972
from line-control.
Related Issues (20)
- How I can disable editing HOT 2
- Line Control (Insert link, image and table) HOT 2
- How to get current/last cursor position if focus is outside the editor.
- Update
- Can't use text Editor HOT 2
- styling issue HOT 1
- Resize while uploading an image HOT 2
- How to "Paste as Plain Text" HOT 1
- I want to add some features to the "Image Attributes" edit page HOT 2
- Table is not re-edit
- Allow Line Control Editor to Support Tabbing HOT 1
- using MathJax.js for displaying formulas
- Enter/return/newline is not working
- How to detect input event changes in the textarea of editor ?
- Problem restoring to editor after pasting any text and saving it to database
- About erasing the space between two HTML tags
- URL in the image is not removed
- How to show beautiful html code in source code viewing area? HOT 2
- Viewing Text in Editor displays everything in Bold including the Font, Formatting and Font Size Buttons .
- How can I hide the toolbar? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from line-control.