Comments (6)
You can currently do it like this:
var formData = $(e.target).textext()[0].tags()._formData,
list = eval(formData);
// duplicate checking
if (formData.length && list.indexOf(data.tag) >= 0) {
var message = [ data.tag, 'is already listed.' ].join(' ');
alert(message);
data.result = false;
}
from jquery-textext.
where to do this above for duplicate checking...
from jquery-textext.
So, into which event should this code be contained? Tried inside setSuggestions and isTagAllowed and none worked.
from jquery-textext.
You do something like this:
$('#textarea').textext({
plugins: 'tags ajax autocomplete filter',
ajax : {
url : 'data.php',
dataType : 'json',
cacheResults : false
}
}).bind('isTagAllowed', function(e, data){
var formData = $(e.target).textext()[0].tags()._formData,
list = eval(formData);
// duplicate checking
if (formData.length && list.indexOf(data.tag) >= 0) {
var message = [ data.tag, 'is already listed.' ].join(' ');
alert(message);
data.result = false;
}});
from jquery-textext.
Why not make this the default behavior or at the very least, a part of the core options?
The most common use case scenario for this plugin is tagging and I have not come across any tagging scenarios where duplicates are desirable (Bookmarking, StackExchange, Blogs, etc).
from jquery-textext.
Hey @alexgorbatchev
Nice work!
...But...
I have to agree with @aleemb ... I would rarelly or even never want duplicates.
Cheers and keep up the good work!
from jquery-textext.
Related Issues (20)
- Line-height issue
- How to validate empty textbox with jquery validate method
- Tags: input value is deleted when Enter is pressed, not when tag is added HOT 1
- Install
- Validate on blur HOT 2
- Initialization issue HOT 2
- outerHeight and outerWidth need to be updated
- Endless ajax-requests after focus HOT 1
- Same option can select again
- destroy
- Better integration with bootstrap style HOT 3
- taking too time to show suggestion autocomplete and sometime browser also hanged HOT 1
- show suggestion when textbox is focused.
- 绑定id和name,显示的是name,如何在标签完成后,就马上获得id
- 如何获取标签的回车事件
- How can I limit character lenght for AJAX call?
- Add a tag of subset of the Autocomplete suggestion word.
- Tagging some parts of a text
- Width not calculated correctly HOT 1
- About update 2.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-textext.