Snip
|
A few years back I wrote a Javascript library for editin...
|
---|
Categories |
|
---|
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.
Current Version: 0.1.2 (Change Log)
Download: jeip.js
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.
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’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.</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’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’t like the default look of the demo there are lots of methods for changing it.</p> <h3>Examples</h3> <p>Here’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> |
---|