Closed pergardebrink closed 9 years ago
This can already be done by subsequent calls to clear() and append(), but you're right, it might be usefull as a separate method
I just don't know, is it better to pass marked up value, or just an object, like this
$('.mentions').mentionsInput('setValue', 'Hey ', {name: 'alex', uid: 'user:1'})
Yes, I did thought about using clear() and then append() but it didn't let me pass marked up value in the same format as getValue() returns, so then I would need to first parse the value myself before appending..
My use case needed me to be able to set the markup directly as a string (I am using it with KnockoutJS and needed to set the value directly from my custom binding).
Maybe there could be different versions for getting/setting the value in either string format or in marked up format as an object. Something like this (don't know about the names though)
$('.mentions').mentionsInput('setValue', 'Hey @[alex](user:1)');
$('.mentions').mentionsInput('setMarkup', [ 'Hey ', {name: 'alex', uid: 'user:1' ]);
$('.mentions').mentionsInput('getValue'); // Returns 'Hey @[alex](user:1)'
$('.mentions').mentionsInput('getMarkup'); // Returns a javascript array in marked up format: [ 'Hey ', {name: 'alex', uid: 'user:1' ]
Hmm. Do all my commits to my fork automatically show up here? That wasn't my intention really since I'm just getting my fork up to sync with my customized version I have.. (although the minLength property is something I was missing. I needed to show all available options without needing to know the first character)
This makes sense. I finally decided to throw away the append() method, and added setValue() method, which supports both ways of passing mentions, marked up, and object-style mentions.
$textarea.mentionsInput('setValue', 'Hello, @[Alex](user:123)');
$textarea.mentionsInput('setValue', 'Hello, ', {name: 'alex', uid: 'user:123'});
Yes, all your commits are automatically appended to pull request. You'd better create a branch for every pull request you want to make.
This was I function that I needed in order to set the value after it had been initialized. Maybe it could be useful for others as well? I'm new to GitHub so I apologize if I'm doing this pull request wrong.. ;)
I also fixed a bug in the init function that checks if it's an INPUT, TEXTAREA element