login/register

Snip!t from collection of Alan Dix

see all channels for Alan Dix

Snip
summary

A few years back I wrote a Javascript library for editin...
Fast forward a few years and the momentum in the Javascr ...
Downloads
Current Version: 0.1.2 (Change Log)
... t is used to replace the contents of the edited element.

jQuery Edit In Place (JEIP) || Joseph Scott
http://josephscott.org/code/javascript/jquery-edit-in-place/

Categories

/Channels/techie/JavaScript

[ go to category ]

/Channels/techie/web development

[ go to category ]

For Snip

loading snip actions ...

For Page

loading url actions ...

A few years back I wrote a Javascript library for editing content in place, that was based on Prototype. It was modeled after the Flickr UI/approach. Nothing amazing, but it worked well enough.

Fast forward a few years and the momentum in the Javascript library field has moved decidedly to jQuery. I’ve been meaning to write a port of the edit in place code to use jQuery, and now I finally have. To help confusion with the original code I’m calling it jQuery Edit In Place, or JEIP for short.

Downloads

Current Version: 0.1.2 (Change Log)
Download: jeip.js

Demo

I’ve put together a very basic demo. Everything is done with templates and CSS classes, so if you don’t like the default look of the demo there are lots of methods for changing it.

Examples

Here’s the most basic example, it enables in line editing for the page element that has an id of content.

1.$( "#content" ).eip( "save.php" );

After editing is complete and the user clicks on the save button the script sends the url, form_type, element id, original value and new value data via HTTP post to save.php. The returned data is expected to be in JSON object, with the following values: is_error, error_text and html. The is_error field is a boolean, and error_text is used to provide information about the error condition. The html is a string that is used to replace the contents of the edited element.

HTML

<p>A few years back I wrote a Javascript library for editing content in place, that was based on <a href="http://www.prototypejs.org/">Prototype</a>. It was modeled after the <a href="http://flickr.com/">Flickr</a> UI/approach. Nothing amazing, but it worked well enough.</p> <p>Fast forward a few years and the momentum in the Javascript library field has moved decidedly to <a href="http://jquery.com/">jQuery</a>. I&#x2019;ve been meaning to write a port of the edit in place code to use jQuery, and now I finally have. To help confusion with the original code I&#x2019;m calling it jQuery Edit In Place, or JEIP for short.</p> <h3>Downloads</h3> <p>Current Version: 0.1.2 (<a href="http://jeip.googlecode.com/svn/tags/0.1.2/changelog.txt">Change Log</a>)<br> Download: <a href="http://jeip.googlecode.com/svn/tags/0.1.2/jeip.js">jeip.js</a></p> <h3>Demo</h3> <p>I&#x2019;ve put together a very <a href="/projects/code/javascript/jeip/example/">basic demo</a>. Everything is done with templates and CSS classes, so if you don&#x2019;t like the default look of the demo there are lots of methods for changing it.</p> <h3>Examples</h3> <p>Here&#x2019;s the most basic example, it enables in line editing for the page element that has an id of content.</p> <div class="syntaxhighlighter" id="highlighter_662052"><div class="bar"><div class="toolbar"><a class="item viewSource" style="width: 16px; height: 16px;" title="view source" href="#viewSource">view source</a><div class="item copyToClipboard"><embed id="highlighter_662052_clipboard" type="application/x-shockwave-flash" title="copy to clipboard" allowscriptaccess="always" wmode="transparent" flashvars="highlighterId=highlighter_662052" menu="false" src="http://josephscott.org/wp-content/plugins/syntaxhighlighter/syntaxhighlighter/scripts/clipboard.swf" height="16" width="16"></div><a class="item printSource" style="width: 16px; height: 16px;" title="print" href="#printSource">print</a><a class="item about" style="width: 16px; height: 16px;" title="?" href="#about">?</a></div></div><div class="lines"><div class="line alt1"><code class="number">1.</code><span class="content"><span class="block" style="margin-left: 0px ! important;"><code class="plain">$( </code><code class="string">"#content"</code> <code class="plain">).eip( </code><code class="string">"save.php"</code> <code class="plain">);</code></span></span></div></div></div> <p>After editing is complete and the user clicks on the save button the script sends the url, form_type, element id, original value and new value data via HTTP post to save.php. The returned data is expected to be in <a href="http://json.org/">JSON</a> object, with the following values: is_error, error_text and html. The is_error field is a boolean, and error_text is used to provide information about the error condition. The html is a string that is used to replace the contents of the edited element.</p>