X - editable input editable on click on other element

前端 未结 1 974
萌比男神i
萌比男神i 2021-01-31 05:05

I have an x-editable input, which I\'m using to edit usernames. The default action of the element is when you click on itself, you can edit a value. But I want to enable click o

1条回答
  •  情歌与酒
    2021-01-31 05:29

    It has a function called enable you can use that to enable edit

    $('.edit').click(function(e){    
           e.stopPropagation();
           $('#publicname-change').editable('toggle');
    });
    

    This won't work if you don't add the first line because default behaviour is to disable edit on click of any other element.

    Edit:

    To enable editing only on the click of edit button and not the text, set toggle property to manual.

    $('#publicname-change').editable({
        type: 'text',
        url: '/post',
        pk: 1,
        placement: 'top',
        title: 'Enter public name',
        toggle:'manual'
    }
    

    JSFiddle

    0 讨论(0)
提交回复
热议问题