jQuery插件editable
来源:互联网 发布:淘宝纯棉四件套店铺 编辑:程序博客网 时间:2024/05/18 14:29
将选定的元素变为“可编辑”:
即,当用户点击该元素时,显示一个编辑框,编辑框失去焦点(或其他特定事件)时,将编辑框的内容回存到该元素。
该元素可能是div,span,td等。
(function ($) { $.joytech._editable = { _editor: null, _richeditor: null, _currenteditor: null, _holder: null, _blur: function (event) { var pthis = $.joytech._editable; if (pthis._holder) { var e = $(pthis._holder); switch (e.attr("joytech_editable_type")) { case 'text': e.text(pthis._currenteditor.value); break; case 'html': e.html(pthis._currenteditor.value); break; case 'value': e.val(pthis._currenteditor.value); break; } pthis._holder = null; $(pthis._currenteditor).hide(); } return false; }, _click: function (event) { var pthis = $.joytech._editable; if (pthis._editor == null) { $(document.body).append("<input type='text' style='position:absolute;' id='joytech__editable__editor'/>"); pthis._editor = $('#joytech__editable__editor')[0]; $(pthis._editor).blur($.joytech._editable._blur).hide(); } if (pthis._richeditor == null) { $(document.body).append("<textarea style='position:absolute;' id='joytech__editable__richeditor'/>"); pthis._richeditor = $('#joytech__editable__richeditor')[0]; $(pthis._richeditor).blur($.joytech._editable._blur).hide(); } pthis._holder = event.target; var e = $(event.target); var bricheditor = (e.attr("joytech_editable_type")) == 'html' && (e.attr("joytech_editable_usingricheditor")=='true'); if (bricheditor) pthis._currenteditor = pthis._richeditor; else pthis._currenteditor = pthis._editor; var i = $(pthis._currenteditor); var value = ''; switch (e.attr("joytech_editable_type")) { case 'text': value = e.text(); break; case 'html': value = e.html(); break; case 'value': value = e.val(); break; } if (bricheditor) i.val(value); else i.val(value); var o = e.offset(); i.css({ left: o.left, top: o.top, width: e.width(), height: e.height() }).show().focus(); return false; } }; $.fn.editableHTML = function (usingricheditor) { this.attr("joytech_editable_type", "html"); this.attr("joytech_editable_usingricheditor", usingricheditor); this.click($.joytech._editable._click); return $; }; $.fn.editableText = function () { this.attr("joytech_editable_type", "text"); this.click($.joytech._editable._click); return $; }; $.fn.editableValue = function () { this.attr("joytech_editable_type", "value"); this.click($.joytech._editable._click); return $; };})(jQuery);
示例:
$(document).ready(function () { $("#editableText td").editableText(); $('#editableHTML td').editableHTML(false); $('#editableHTML_Div').editableHTML(true); });
功能还有待完善
下载:
http://download.csdn.net/detail/tiewen/4297662- jQuery插件editable
- select下拉框插件jquery.editable-select
- jQuery插件之jquery editable plugin--点击编辑文字插件
- jquery>editable plugin
- select下拉框插件jquery.editable-select的用法以及注意事项
- Editable
- select选择框控件-jquery.editable-select
- jquery-editable-select设置显示默认选项
- 有熟悉editable插件的高手请指教
- ExtJS中editable、readOnly、disabled区别,jQuery与ExtJS区别
- 关于在线编辑,点击即可编辑失去焦点即可保存的插件X-editable
- editable select
- Android Editable
- x-editable
- jquery插件
- jquery 插件
- jQuery插件
- jquery 插件
- The Kernel Boot Process --linux2.6.25内核启动过程
- TNC-可信网络接入介绍(一)
- Google Hacking
- 按某字节对齐分配内存
- 需要谈谈的游戏测试(九)
- jQuery插件editable
- 做程序员多年的经验总结
- Java内存管理
- Tiling(P2506)
- php中正则的断言匹配
- 常用工具
- c语言实现顺序表的插入,删除和求给定元素在表中的位序等运算
- Flex中的TextInput (2):画出边框---Graphics
- 个人喜欢的命名方法