Simple Jquery editor to edit HTML5 text and save with ajax. Inline editing with jQuery and PHP Jquery text editor
As you know, inline editing, or in other words, the ability to edit content directly on the page, is a very useful thing that should always be at your fingertips. I will tell you how it all works, and also show you how with using PHP instantly update the edited part on the page, and how to make all the changes to the database.
Code
Now I'll explain what inline editing is all about.
On the Demo page, you will see a block with some text. Hover your cursor over any part of this block and you will see a small edit icon. It looks like a Facebook icon.
If you click inside the block with the text or on the icon itself, the block will be replaced with the textarea form, and the save and cancel buttons will appear at the bottom.
Now in more detail
I used binding and unbinding. In simple words, we can bind a mouse click event to the element. Conversely, you can “take away” this event from an element. It's pretty simple. In the 9th line of the code below, we assign a click event to all elements with the “inlineEdit” class, and assign the “updateText” function to the handler. This means that every time you click inside the "inlineEdit" block, the "updateText" function will run. This function replaces a block of text with the form textarea.
Now let's look at the save function. It will run only when you click on the “Save” button. Here we just push the edited text into a variable and run it through the update.php file. You will notice that while the update is in progress, a download icon is displayed. We will also display a response message from the PHP page. Finally, we will remove the “selected” class from the element and then insert the updated text from the textarea, entered by the user, into the div block.
The cancel function will run when the element with the .revert class is activated. This function simply removes the “selected” class as in the previous function, but inserts the original text into the div, not the edited text.
$ (document) .ready (function () (function slideout () (setTimeout (function () ($ ("# response"). slideUp ("slow", function () ());), 2000);) $ (".inlineEdit"). bind ("click", updateText); var OrigText, NewText; $ (". save"). live ("click", function () ($ ("# loading"). fadeIn (" slow "); NewText = $ (this) .siblings (" form "). children (". edit "). val (); var id = $ (this) .parent (). attr (" id "); var data = "? id =" + id + "& text =" + NewText; $ .post ("update.php", data, function (response) ($ ("# response"). html (response); $ (" #response "). slideDown (" slow "); slideout (); $ (" # loading "). fadeOut (" slow ");)); $ (this) .parent (). html (NewText) .removeClass ( "selected"). bind ("click", updateText);)); $ (". revert"). live ("click", function () ($ (this) .parent (). html (OrigText) .removeClass ("selected"). bind ("click", updateText);)); function updateText () ($ ("li"). removeClass ("inlineEdit"); OrigText = $ (this) .html (); $ ( this) .addClass ("selected"). html ("
![](https://i2.wp.com/images/save.png)
![](https://i0.wp.com/images/cancel.png)
PHP
Html
HTML is very simple and consists of a single list item with the class “inlineEdit”, which makes it editable. You can add as many editable elements as you like to the page, but remember to assign a unique ID to each one.
jQuery Inline-Edit ![](https://i2.wp.com/images/loading.gif)
Click the text below to edit it.
- Lorem Ipsum ....
Looking for free to use rich text editors? If so, then you are lucky to be on the right page. In this review, we bring you 10 great free Rich-Text editors. Rich text editors allow you to edit and type from a web browser. They are used in different ways, providing the user with the ability to post generated and formatted content by him.
We hope our list will offer you the really best solutions. Feel free to share it with your friends, and with us your opinions on this collection. Here is a complete list.
Happy viewing!
CKEditor is a free open source HTML text editor designed to make it easier for you to fill your website with content. A WYSIWYG editor that gives you access to familiar word processor functions right from the web. Enhance your website experience with this community-powered editor.
markItUp! Not conceived as an always-ready-and-of-all-trades editor. On the contrary, it is a very compact, flexible in configuration and operation service that can serve a developer when debugging his CMS, blogs, forums or websites. markItUp! is not a WYSIWYG editor and never will be.
NicEdit- compact, cross-platform, embeddable content editor for varying website content easily and simply right in the browser.
TinyMCE is an off-platform javascript / HTML WYSIWYG editing console released as an open source web-based resource and protected by the LGPL. TinyMCE can convert HTML TEXTAREA fields and other HTML elements into edit units.
Free cross-platform WYSIWYG editor packed with all the rich text editing features you need to dramatically improve your content management system.
jQuery TE is a jQuery module. Compact (19.5 Kb) and very easy to use HTML editor. Works according to WYSIWYG scheme.
Most importantly, it can be embedded in your system in just 1 minute. And its interface can be modified as you like. Even CSS classes can be replaced.
Looking for a no-nonsense Rich-Text text editor for jQuery resources? You have come to the right place!
A simple, compact, extensible jQuery-based HTML editor that works in a WYSIWYG manner. A facility to easily display a WYSIWYG HTML editor in place of any TextArea DOM element within the page. The lightweight script "weighs" 9.17 Kb; CSS with pictures together "pull" 25.9 Kb.
uEditor flexible and easy to use. Produces a clear, workable code (albeit one that requires certification in the prescribed manner), among other things, you can use your own style sheet to work in WYSIWYG mode. The functionality of the service can be further enhanced thanks to an easy-to-use system of additional modules.
With Whizzywig, it's simple. Allows you to compose rich formatted text in a web window. He's actually writing in XHTML, but you don't need to know HTML to use it. If you know how to use a word processor or e-mail, then you can do it too.
I was looking for a visual editor that was pleasing to the eye so that I didn't have to redo the design and waste time. In the process, I found and tested several visual editors. Installing visual editors on a site presents a simple system of actions. It is necessary to put a number of requests for scripts in the HEAD tag (after uploading the entire folder with the visual editor to the server). The downloaded files usually provide a demo version of use, it is from the code of this page that you can easily get the names of the scripts you need. Here is a small code used in the BODY page for direct use of the editor. We will place it in the place in the html-form where we need it.
Visual editors are divided into views using different processing. So, I met visual editors based on jQuery, MooTools, ActiveX and just JavaScript.
Visual editors using MooTools
I came across some very interesting visual editors based on this technology. However, due to incompatibility with jQuery scripts already used on the site for other needs, I continued to search for something more universal.
MooEditable visual editor example using MooTools
Scripts Inserted Between Tags<HEAD>HEAD>:
Use in
The standard form tag TEXTAREA is used here, which will make the input field workable even if disabled
JavaScript for the user (although all options of the visual editor will not work).
Download visual editor MooEditable
Example ggEdit, a visual editor based on MooTools
In FireFox, this visual editor ("ggEdit") refused to work at all. As a Mozilla user, this didn't suit me at all.
However, I liked the interface of such a visual editor (example "ggEdit" (the source can be downloaded)).
JQuery based visual editors
This visual editor (WKRTE) would probably be nice if the modular windows (image insertion, links) didn't pop up outside the screen frame
Example WKRTE, jQuery based visual editor:
It is noteworthy that the main scripts are not inserted in
… where basically style requests (CSS):
The main scripts will appear before the closing tag