2013-09-27 35 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倉庫中。