使用 Jeditable 保存编辑值
我一直在寻找一个非常好的、文档齐全的 jquery 插件,它可以让我通过单击另一个按钮来编辑值。
Jeditable 是我找到的最接近的,但是我不知道如何获取它保存,即使在测试中也是如此。非常快地返回值的东西。
我将其用于我的 php 脚本:
function editprofile()
{
$this->input->post('value');
}
这是我的 JS 脚本:
$("a.edit").live('click', function(){
$(this).parent("li").find("span.detail").editable('profile/editprofile',
{
indicator : 'Saving...',
submit : 'OK',
tooltip : 'Click to edit...'
});
});
这是我的 HTML:
<span id="city" class="detail">Philadelphia</span>
<a href="javascript:;" class="edit">Edit</a>
已修复: php 应该是:
echo $this->input->post('value');
I have been looking for a really good, well documented jquery plug-in that will let me edit values on click of another button.
Jeditable is the closest I've found yet, However I am not sure how to get it to save, even in testing. Something really quick that returns the value.
I am using this for my php script:
function editprofile()
{
$this->input->post('value');
}
This is my JS script:
$("a.edit").live('click', function(){
$(this).parent("li").find("span.detail").editable('profile/editprofile',
{
indicator : 'Saving...',
submit : 'OK',
tooltip : 'Click to edit...'
});
});
This is my HTML:
<span id="city" class="detail">Philadelphia</span>
<a href="javascript:;" class="edit">Edit</a>
Fixed:
php should be:
echo $this->input->post('value');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Jeditable,
来自 Jeditable 的示例:
因此,
save.php
应该返回(打印到页面)将在编辑位置显示的文本(而不是 html)。它还应该保存对数据库的更改或您应该执行的任何其他服务器端工作。您使用 javascript 发布,并向客户端回显响应。 http://img34.imageshack.us/img34/3412/savephp.png
在
save.php
上,您可以执行任何存储新值的操作。这里有另一个教程jQuery 的行编辑器。
Jeditable,
From Jeditable's example:
So
save.php
should return (print to the page) the text (not the html) that is going to be showed in the edited place. It should also save the changes on the database or any other serverside work that you should do.You post with javascript, and echo to the client the response. http://img34.imageshack.us/img34/3412/savephp.png
On
save.php
you do anything you store the new value.Here you have another tutorial for the in-line editor for jQuery.
toggledit 有一个简单的回调机制(onpreview、onedit),以及一个简单的公共方法api(edit、preview) )。
要保存,您可以编写自己的 ajax 函数,当触发这些或其他一些事件时,该函数将触发...例如,如果单击保存按钮。
用于切换到编辑模式的侦听器也是可配置的 - 您可以传入按钮选择器:
此外,您可以使用公共事件从按钮手动触发编辑和预览:
另请参阅 https://stackoverflow.com/questions/708801/whats-the-best-edit-in- place-plugin-for-jquery/ :>
toggledit has a simple callback mechanism (onpreview, onedit), and a simple public method api (edit, preview).
To save, you would write your own ajax function that would fire when these or some other events are triggered... e.g. if a save button gets clicked.
The listener for switching to edit mode is also configurable - you can pass in your button selector:
also, you could manually trigger edit and preview from your button using public events:
please also see https://stackoverflow.com/questions/708801/whats-the-best-edit-in-place-plugin-for-jquery/ : >