vitalets / x-editable

In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
http://vitalets.github.io/x-editable
MIT License
6.51k stars 1.72k forks source link

Change value when textarea is clicked! #1009

Closed ianrussel closed 7 years ago

ianrussel commented 7 years ago

I only need to display the first 20 characters if my textarea contains more than 20 character, then show the original value when editable is click.This is my code

original string = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat';

 `<td id="comment_{{ $admin->id }}" style="border-right: none; height: 30px;">
         <a href="#" id="comment" data-type="textarea" data-pk="{{ $admin->id }}"> {{ substr($admin->comment,0,19)}} </a>
  </td>`

  `$('.comment,#comment').on('click',function() {
            // var data = $(this).attr('data-original-title');
            // console.log($(this).closest('form').find('div.editable-input'));
            //$(this).html("tala");
            carousel.stop();
            if(!parent.parent.modal()){
                if($(this).hasClass('editable') && !$(this).hasClass('editable-disabled')) {
                    $(this).editable('toggleDisabled');
                }
                console.log("you are not authorised");
            } else {
                if($(this).hasClass('editable') && $(this).hasClass('editable-disabled')) {
                    $(this).editable('toggleDisabled');
                }
            }
        }
        ).editable({
            placement: 'right',
            title: 'Enter comments of you',
            url: '/partA-admin-update',`

Now I want to display full comment when textarea is click, to show the user the full length of the comment. How would you implement this? I tried finding the closest form textarea and add original value, but did not work lorem

update

Ok I tried added this piece of code after placement

value:$(this).attr('data-value'),

But this will throw 'undefined' when saving

MarQuisKnox commented 7 years ago

Unfortunately, due to this project being supported by volunteers we cannot provide user support at this time. Please try a site like Stack Overflow: http://stackoverflow.com/questions/tagged/x-editable

Thank you.

ianrussel commented 7 years ago

Thank you @MarQuisKnox