2013-09-27 34 views
3

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

enter image description here

我为使用jquery editInPlace制作链接的可编辑的文本。链接的文本可以编辑,但我不能在文本编辑后恢复链接属性。 这里是我的html和javasrcript文件

demo.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的克隆https://github.com/VihaanVerma89/dummy.git

+0

当您说“链接文本变为可编辑但我不能在文本编辑后恢复链接属性。”你有什么具体问题?链接目标是否丢失/未设置? – Yablargo

回答

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仓库中。