今天想做一个在线编辑的东西,翻遍了图书,讲的都是用in_place_edit_for在controller里面添加一个方法,然后在相应的视图里面添加一个in_place_editor_field的help方法,在实现现场编辑功能,但是如果需要实现现场编辑功能的时候,并没有配套的controller怎么办……查询了Rails的类库,发现除了上述提到的2个以外,还有一个in_place_editor方法,直接在视图里面添加,不需要另外添加什么方法,直接指定需要现场编辑的HTML元素的DOM ID即可。
以下摘自Rails1.2.6的类库:
in_place_editor(field_id, options = {})
DEPRECATION WARNING: This method will become a separate plugin when Rails 2.0 ships.
Makes an HTML element specified by the DOM ID field_id become an in-place editor of a property.
A form is automatically created and displayed when the user clicks the element, something like this:
<form id="myElement-in-place-edit-form" target="specified url">
<input name="value" text="The content of myElement"/>
<input type="submit" value="ok"/>
<a onclick="javascript to cancel the editing">cancel</a>
</form>
The form is serialized and sent to the server using an AJAX call, the action on the server should process the value and return the updated value in the body of the reponse. The element will automatically be updated with the changed value (as returned from the server).
Required options are:
:url: |
Specifies the url where the updated value should be sent after the user presses "ok". |
Addtional options are:
:rows: |
Number of rows (more than 1 will use a TEXTAREA) |
:cols: |
Number of characters the text input should span (works for both INPUT and TEXTAREA) |
:size: |
Synonym for :cols when using a single line text input. |
:cancel_text: |
The text on the cancel link. (default: "cancel") |
:save_text: |
The text on the save link. (default: "ok") |
:loading_text: |
The text to display while the data is being loaded from the server (default: "Loading…") |
:saving_text: |
The text to display when submitting to the server (default: "Saving…") |
:external_control: |
The id of an external control used to enter edit mode. |
:load_text_url: |
URL where initial value of editor (content) is retrieved. |
:options: |
Pass through options to the AJAX call (see prototype’s Ajax.Updater) |
:with: |
JavaScript snippet that should return what is to be sent in the AJAX call, form is an implicit parameter |
:script: |
Instructs the in-place editor to evaluate the remote JavaScript response (default: false) |
:click_to_edit_text::The text shown during mouseover the editable text (default: "Click to edit")
哎……早知道就自己查查类库了,省得一开始还弄的那么麻烦,还想着单独建立一个controller……
在view里面:
<span id="xxx"><%= 需要现场编辑的内容%></span>
<%= in_place_editor "xxx",:url=>{用来处理提交数据的方法}%>
分享到:
相关推荐
使用方法与示例** 在项目中引入jQuery库和jQuery编辑器插件后,可以快速为特定DOM元素启用编辑功能。以下是一个简单的应用示例: ```html <!DOCTYPE html> <title>jQuery Editor Demo ...
使用方法: 1、解压至C:\Program Files目录下(密码:xiaoqing); 2、双击导入注册表C:\Program Files\BCGSoft\BCGControlBarPro\bcgcontrolbarpro.12.00.reg; 3、运行向导C:\Program Files\BCGSoft\BCGControlBar...
第四章“A place for Components”中,详细介绍了各种组件的使用方法,包括按钮、标签、输入框等,并通过示例演示了如何将它们组合在一起以构建更复杂的用户界面。第五章“Organizing Components”则探讨了如何使用...
### ORCAD9.2 教程知识点...通过熟练掌握其快捷键和工具栏的使用方法,可以显著提高设计效率。此外,对于遇到的问题和技术支持需求,可以通过上述联系方式寻求帮助。希望本教程能为您的学习之路提供有效的指导和支持。
aspjpeg组件高级使用方法介绍2007-10-13 16:471、什么是AspJpeg? AspJpeg是一款功能强大的基于Microsoft IIS环境的图片处理组件,网络上对其进行详细和深入介绍的中文文章并不多,即使有一般也只是牵涉到图片缩略...
文档中还涵盖了DataExporter、DataGrid、DataList、DataScroller、DataTable、Diagram、Dialog、Drag&Drop、Editor、Effect、FeedReader、Fieldset、FileDownload、FileUpload、Focus、Fragment、Galleria、GMap、...
1. **创建模板列**:在 In-Place Editor Repository 中,你可以选择 ADD 添加各种类型的模板列。例如,选择 LookUpEdit,它提供了一个小型的网格视图,可用于筛选和选择信息。 2. **绑定模板列**:回到 Columns,...
- **第4章:组件的位置**(A place for Components):解释了如何在应用中组织和使用Ext JS组件。 - **第5章:组织组件**(Organizing Components):进一步探讨了如何有效地管理和布局多个组件。 - **第6章:Ext...
这篇文章将介绍如何在 Altium Designer 中快速进行差分对走线的方法。 在进行差分对走线之前,需要在原理图中定义差分对。可以通过在原理图中让一对网络名称的前缀名相同,后缀分别为_N 和_P,左键点击 Place/...
`df.drop('column_name', axis=1, inplace=True)`,其中'inplace=True'表示直接在原始DataFrame上进行修改,而'axis=1'表示我们按列进行操作。 3. **设置为None**:另一种方法是将列赋值为None,但请注意这并不实际...
the resource editor in this file. ///////////////////////////////////////////////////////////////////////////// For the main frame window: MainFrm.h, MainFrm.cpp These files contain the frame ...
表示不显示@后面的命令,在入侵过程中(例如使用批处理来格式化敌人的硬盘)自然不能让对方看到你使用的命令啦。 Sample:@echo off @echo Now initializing the program,please wait a minite... @format X: /q/u...
- **Virtuoso-XL 中的互连创建方法:** 介绍如何使用 Virtuoso-XL 的 Wire Editor 工具来绘制复杂的互连线,并讨论如何优化互连线路径以减少信号延迟和功耗。 - **高级互连技术:** 探讨一些高级的互连技术,如多层...
使用该方法,您必需创建两个AspJpeg实例对象 Set Jpeg1 = Server.CreateObject("Persits.Jpeg") Set Jpeg2 = Server.CreateObject("Persits.Jpeg") Jpeg1.Open Server.MapPath("t.jpg") Jpeg2.Open ...
arcgis工具总结 1. 要素的剪切与延伸 实用工具 TASK 任务栏 Extend/Trim feature 剪切所得内容与你画线的方向有关。 2. 自动捕捉跟踪工具 ...例如,使用包含(Contain)方法,即使湖泊的边界和包含该...
- `-i`:表示就地编辑(inplace edit),直接修改原文件,不生成备份。如果不想直接修改原文件,可以去掉这个选项。 - `s/zhangsan/lisi/g`:这是sed的替换命令,`s`代表替换,`zhangsan`是要查找的字符串,`lisi`是...
在设计器中,选择"In-Place Editor Repository",添加所需的编辑器类型,如`LookUpEdit`。然后,将模板列与数据列绑定。`LookUpEdit`常用于提供下拉列表式的筛选和编辑功能。 - 创建`LookUpEdit`(假设命名为`Re1`...
- `-i[扩展名]`, `--in-place[=扩展名]`:直接修改文件,若指定了扩展名,则原文件会被备份。 - `-lN`, `--line-length=N`:设置使用`l`命令时的换行长度。 - `--posix`:禁用所有的GNU扩展特性,确保与POSIX标准...
3. **jQUploader**:一个轻量级的jQuery文件上传插件,易于配置和使用。 - **特性**:拖拽上传、多文件上传。 - **应用场景**:适用于需要快速集成文件上传功能的应用场景。 4. **MultipleFileUpload plugin**:...