3

我有一个链接和一个按钮并排放置。当用户点击按钮时,链接的文本应该变成可编辑的。

在此处输入图像描述

我正在使用 jquery editInPlace 使链接的文本可编辑。链接的文本变为可编辑,但我无法在文本编辑后恢复链接属性。这是我的 html 和 javasrcript 文件

演示.js

1 $(document).ready(function(){                                                                                                                                                                       
 2     $("img.modifyButton").click(function(){                                                                                                                                                         
 3         $(this).prev().editInPlace({                                                                                                                                                                
 4             success: function(){                                                                                                                                                                    
 5                 $(this).unbind('.editInPlace');                                                                                                                                                     
 6                 $(this).unbind('click');                                                                                                                                                            
 7             },
 8             url:'Admin/p.inline_coupon_edit_frontend.php',
 9             text_size:55,
10             show_buttons: false,
11             params:"field=Title"
12         });
13 
14         $(this).prev().on('click', function(event)
15                 {
16                     event.preventDefault();
17                 });
18         $(this).prev().click();
19     });
20 
21 });

.html 文件

16         <div class="crux">                                                                                                                                                                          
17           <a  href="www.google.com">title</a>                                                                                                                                                       
18           <img class="modifyButton" src="./editInPlace_files/modifyButton.png" alt="None" width="13" height="13">
19         </div>

git repo 代码:git clone https://github.com/VihaanVerma89/dummy.git

4

1 回答 1

4

不太确定你的问题是什么。你的 php 文件是空的,但是当使用回调而不是你的 PHP 文件时,一切似乎都正常——链接目标是完整的。

你的版本出了什么问题?您是否从 php 文件中返回值?如果不是这样,我相信这将失败

http://jsfiddle.net/raNFr/2/

这似乎工作得很好,除非我错过了你想要做的事情:

$(document).ready(function(){
    $("img.modifyButton").click(function(){
        $(this).prev().editInPlace({
            success: function(){
                $(this).unbind('.editInPlace');
                $(this).unbind('click');
            //  alert('success');
            },
            error: function(){
                $(this).unbind('.editInPlace');
                $(this).unbind('click');
                //alert('error');
            },

            callback: function(b,abc){
                return abc;
            },
            text_size:55,
            show_buttons: false
            ,params:"field=Title"
        });

        $(this).prev().on('click', function(event)
                {
                    event.preventDefault();
                });
        $(this).prev().click();
    });

});

我认为问题出在你的 php 脚本上——上面是你的例子,没有包含 php——因为它没有包含在你的 git repo 中。

于 2013-10-01T14:57:31.373 回答