Closed charlie-eth closed 9 years ago
Just pass a url, which does the search, to the source
param of the plugin, like this
$('textarea').mentionsInput({source: 'http://example.com/users.json'})
But how can I pass the search query?
When you type @BR
, plugin queries url http://example.com/users.json?term=BR
Oh I get it, thank you very much!
Just another question, why does the input background needs to be transparent for the highlight to work?
I changed line 323 from transparent to white and the hightlight wouldn't work after that!
Also, whilst I have you, is there a way to get the response from getValue as json?
I get this format @username which is gonna need some playing around with preg_match to achieve what I want (storing them nicely in a database) or am I missing something again?
Sorry about all the questions, jquery isn't really my thing!
A note about background, as far as I understand you are having issues with non-white background, so that your input is also non-white. If that's the case, I've just fixed that issue, download updated code.
Can you provide an example of desired response from getValue
method?
What do you mean by "storing them nicely in a database"?
The standard approach is to pass the string to the server, and then parse the string with regexp to replace mentions by links.
Regarding the highlighter, the issue is that the input background needs to be transparent for the background-color to work on the highlighter but it's not a bug.
A json array like so {name: 'alex', uid: 'user:1'} Getting that from getValue would be a lot easier in my opinion.
This is my input on your latest commit:
Let me know if you want to see it live.
Edit: Nevermind, this is happening because my input is 34px when I initialise the plugin and becomes 76px on focus (but the hightlighter size is already set).
Thanks a lot for your help and the plugin, I won't take anymore of your time!
What you need is an array of all mentions, contained in an input, ignoring any text, right? Such a method could be added easily, since this information is already stored inside of the plugin.
I'll add an issue for your problem with focused textarea, I think it's quite a common scenario.
Would be great to see that method added to easily get the value of the tags without messing about with regex.
Ok thanks, in the meantime, I'm just changing the size of .highlighter on focus
I've added method getMentions
Awesome, thank you!
Hello,
First thank you for the plugin, I've tried many others and yours is by far the best.
Just wondering how I would make a remote ajax call with a parameter? (if I type @BR to make a search on BR in my database and return a json array)
Thank you!