Open dinhtuvu opened 7 years ago
@ivirabyan, please help!
The problem is that when you click on "edit" button, you initializer mentionsInput not only for the edit form, but for the main comment textbox too, which is already initialized. Repeated calls to mentionsInput on the same field leads to incorrect behaviour. So solution is to initialize specific field, not using a common selector '.comment-content'. Future versions may allow repeated calls to plugin, but now it doesn't.
@ivirabyan thank for support! yes, I think so. But i haven't a best solutions. I tried follow code:
function resetMention() {
$('.comment-content[contenteditable=true]').mentionsInput('destroy');
$('.comment-content[contenteditable=true]').mentionsInput({
source: [
{value: 'alex', uid: 'user:1', image :'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/v/t1.0-1/s200x200/999047_174739439370902_95491054_n.jpg?oh=675da21ca6d5800c70b4fcc02b55ac77&oe=58715BB0&__gda__=1483295654_59c5459aa37caee88017beccb3f215e4'},
{value: 'andrew', uid: 'user:2', image :'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/v/t1.0-1/s200x200/999047_174739439370902_95491054_n.jpg?oh=675da21ca6d5800c70b4fcc02b55ac77&oe=58715BB0&__gda__=1483295654_59c5459aa37caee88017beccb3f215e4'},
{value: 'angry birds', uid: 'game:5', image :'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/v/t1.0-1/s200x200/999047_174739439370902_95491054_n.jpg?oh=675da21ca6d5800c70b4fcc02b55ac77&oe=58715BB0&__gda__=1483295654_59c5459aa37caee88017beccb3f215e4'},
{value: 'assault', uid: 'game:3', image :'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/v/t1.0-1/s200x200/999047_174739439370902_95491054_n.jpg?oh=675da21ca6d5800c70b4fcc02b55ac77&oe=58715BB0&__gda__=1483295654_59c5459aa37caee88017beccb3f215e4'}
],
suffix: ' ',
showAtCaret: true
});
}
but still the same error Error when destroy first times
Error when destroy next times
It doesn't work because now you're trying to destroy yet uninitialized textareas. You'd better initialize specific textarea which you just opened dynamically. I can't see your code now, so assuming you textarea is a child of <div id="comment123">
you'd select your textarea like this:
$('#comment123 comment-content[contenteditable=true]')
Thanks! My solution is marked for textareas initialize.
example: http://nhadatanbien.com/comment/index.html step 1: type @a and select one in main comment textbox step 2: click to edit a comment step 3: type @a and select one step 4: return main comment textbox and type @a, select one. bug can't get start position
@ivirabyan how to fix this problem? thank you so much