Comments (6)
I'm guessing you're trying to remove the item by passing the item's value at the 'remove' call. Now the remove tries to find the item by reference, but i think you're right. Might be a good thing to try to find by both reference and value.
from bootstrap-templates.
Hi Tim,
I does not work both reference and value also. Normally, we don't have same object to post it into remove method.
Problem #1: Cannot remove an object from the control
[Setup code]
var
$tags.tagsinput({ itemValue: 'value', itemText: 'text' });
var item = { "value": 1 , "text": "Amsterdam", "type" : "1" };
$tags.tagsinput('add', $item);
$('.btn-remove').click(function() {
$tags.tagsinput('remove', { "value": 1 , "text": "Amsterdam", "type" : "1" }); // does not work
$tags.tagsinput('remove', { "value": 1 }); // does not work
$tags.tagsinput('remove', 1 ); // does not work
$tags.tagsinput('remove', item); // seems to work, but it requires me to create variable to keep the same object reference, not much useful.
});
As checking the code, i think the remove function should remove item with the same value instead of checking objects equally by === operator.
Problem #2: I could add duplicated item (object mode) into the control. IMHO, the control should ignore this if it's not in multiple mode.
My Best,
Hung Tran
from bootstrap-templates.
I fixed these issues in latest release (0.3.0). You should now be able to pass the following as argument to remove a tag:
- exact same object instance as was added, or
- other object instance, but wih the same value, or
- just a value
All 3 scenario's should work.
I also made sure you can just set 1 tag when using a <select /> without multiple. When trying to add a new tag, it removes the one allready set.
Take a look at commit a319af5 for more details. Let me know if you run into any problems.
from bootstrap-templates.
hi Tim,
I have tested all the cases, they are worked perfectly. However, it would be more flexible if i can receive my item which i put into remove method (like i can get the same item when i put it into add method).
var myItem1 = { value: 1, text: 'text 1' };
$tagsInput.add(myItem1);
At itemAdded event, i can get the same reference as what i put into add method (myItem1).
var myItem2 = { value: 1, context: 'gridAction' };
$tagsInput.remove(myItem2);
At itemRemoved event, it returns myItem1 (the object added). It's more flexible if i can get myItem2 instead.
My Best,
Hung Tran
from bootstrap-templates.
Seems a good idea, perhaps providing both is even bettter:
self.$element.trigger($.Event('itemRemoved', { item: item, originalItem: originalItem }));
In which 'item' is the item you passed as an argument, and 'originalItem' is the instance acutally removed from the input.
from bootstrap-templates.
I had a similar problem, the item variable was a number but wasn't removing the item.
However i found it worked with JSON.stringify(item);
from bootstrap-templates.
Related Issues (20)
- add array
- Uncaught TypeError: Cannot read property 'name' of null in bootstrap-tagsinput.js. HOT 2
- Repo activity? HOT 2
- How to append class or text to newly added tag? HOT 1
- How to get text of removed tag HOT 1
- How to return text of clicked tag HOT 1
- how to implement text sanitize on freeInput? HOT 1
- Safe string decodeURI
- tagsinput typeahead empty input have value []
- remove all method issue
- Show hint tags after type three characters HOT 3
- Is there any way to use Typeahead and New tags together? HOT 1
- only show tags
- prevent users from adding tags
- The script limits my tags to 256 symbols for unknown reason. HOT 1
- Jquery security adivisor version
- Support for Bootstrap 4 HOT 2
- delimiter
- No tag found that was able to satisfy 0.7.1 HOT 2
- No versions found
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 bootstrap-templates.