Skip to content

Commit 1c2780f

Browse files
committed
Tag UI: Make sure data is passed to remove action
1 parent 39e1936 commit 1c2780f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

‎ui/scripts/ui/widgets/tagger.js‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@
5656

5757
return $form;
5858
},
59-
tagItem: function(title, onRemove) {
59+
tagItem: function(title, onRemove, data) {
6060
var $li = $('<li>');
6161
var $label = $('<span>').addClass('label').html(title);
6262
var $remove = $('<span>').addClass('remove').html('X');
6363

6464
$remove.click(function() {
65-
if (onRemove) onRemove($li);
65+
if (onRemove) onRemove($li, data);
6666
});
6767

6868
$li.append($remove, $label);
@@ -90,10 +90,12 @@
9090
var $title = elems.info('Tags').addClass('title');
9191
var $loading = $('<div>').addClass('loading-overlay');
9292

93-
var onRemoveItem = function($item) {
93+
var onRemoveItem = function($item, data) {
9494
$loading.appendTo($container);
9595
actions.remove({
96-
context: context,
96+
context: $.extend(true, {}, context, {
97+
tagItems: [data]
98+
}),
9799
response: {
98100
success: function(args) {
99101
var notification = $.extend(true, {} , args.notification, {
@@ -133,6 +135,7 @@
133135

134136
$loading.appendTo($container);
135137
actions.add({
138+
data: data,
136139
context: context,
137140
response: {
138141
success: function(args) {
@@ -147,7 +150,7 @@
147150
// Success
148151
function() {
149152
$loading.remove();
150-
elems.tagItem(title, onRemoveItem).appendTo($tagArea);
153+
elems.tagItem(title, onRemoveItem, data).appendTo($tagArea);
151154
success();
152155
}, {},
153156

@@ -182,8 +185,9 @@
182185
$(data).map(function(index, item) {
183186
var key = item.key;
184187
var value = item.value;
188+
var data = { key: key, value: value };
185189

186-
elems.tagItem(key + ' = ' + value, onRemoveItem).appendTo($tagArea);
190+
elems.tagItem(key + ' = ' + value, onRemoveItem, data).appendTo($tagArea);
187191
});
188192
},
189193
error: function(message) {

0 commit comments

Comments
 (0)