Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I using for a contenteditable div #68

Open
dinhtuvu opened this issue Nov 3, 2016 · 5 comments
Open

I using for a contenteditable div #68

dinhtuvu opened this issue Nov 3, 2016 · 5 comments

Comments

@dinhtuvu
Copy link

dinhtuvu commented Nov 3, 2016

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

@dinhtuvu
Copy link
Author

dinhtuvu commented Nov 8, 2016

@ivirabyan, please help!

@ivirabyan
Copy link
Owner

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.

@dinhtuvu
Copy link
Author

dinhtuvu commented Nov 9, 2016

@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
9015cc1e-a69a-11e6-81c2-a9553bb625a4

Error when destroy next times
77bdda62-a69a-11e6-89f5-c45b010a12ba

@ivirabyan
Copy link
Owner

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]')

@dinhtuvu
Copy link
Author

Thanks!
My solution is marked for textareas initialize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants