문제

I have a link and a button placed side by side. When the user clicks on the button the text of the link should become editable.

enter image description here

I m using jquery editInPlace for making the text of the link editable. The text of the link becomes editable but I m not able to restore the link property after the text edit. Here are my html and javasrcript files

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 file

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 of code : git clone https://github.com/VihaanVerma89/dummy.git

도움이 되었습니까?

해결책

Not really sure what your problem is. Your php file is empty, but when using callback versus your PHP file, everything seems to work right -- the link target is intact.

What is going wrong in your version? Are you returning the value back from your php file? If not this will fail I believe

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

This seems to work just fine, unless I am missing what you are trying to do:

$(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();
    });

});

I think the problem lies in your php script -- the above works as your example, with the php not included -- as it was not included in your git repo.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top