使用 Jeditable 保存编辑值

发布于 2024-08-02 09:30:17 字数 863 浏览 4 评论 0原文

我一直在寻找一个非常好的、文档齐全的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸠魁 2024-08-09 09:30:17

Jeditable

来自 Jeditable 的示例:

在此示例中,load.php 应返回未呈现的 xhtml 标记源。然而 save.php 应该返回渲染的 xhtml。保存时浏览器将准确显示保存脚本返回的内容。还有另一种选择。您可以在数据参数中传递标记源。

因此,save.php 应该返回(打印到页面)将在编辑位置显示的文本(而不是 html)。它还应该保存对数据库的更改或您应该执行的任何其他服务器端工作。

您使用 javascript 发布,并向客户端回显响应。 http://img34.imageshack.us/img34/3412/savephp.png

save.php 上,您可以执行任何存储新值的操作。

这里有另一个教程jQuery 的行编辑器

Jeditable,

From Jeditable's example:

In this example load.php should return the markup source not rendered xhtml. However save.php should return rendered xhtml. When saving the browser will display exactly what saving script returns. There is also another option. You can pass markup source in data parameter.

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.

避讳 2024-08-09 09:30:17

toggledit 有一个简单的回调机制(onpreview、onedit),以及一个简单的公共方法api(edit、preview) )。

要保存,您可以编写自己的 ajax 函数,当触发这些或其他一些事件时,该函数将触发...例如,如果单击保存按钮。

用于切换到编辑模式的侦听器也是可配置的 - 您可以传入按钮选择器:

$(form).find('input,select').toggleEdit({
    listeners: {
        edit: '#your_button'
    }
});

此外,您可以使用公共事件从按钮手动触发编辑和预览:

$(el).toggleEdit('edit');
$(el).toggleEdit('preview');

另请参阅 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:

$(form).find('input,select').toggleEdit({
    listeners: {
        edit: '#your_button'
    }
});

also, you could manually trigger edit and preview from your button using public events:

$(el).toggleEdit('edit');
$(el).toggleEdit('preview');

please also see https://stackoverflow.com/questions/708801/whats-the-best-edit-in-place-plugin-for-jquery/ : >

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文