Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Pass affected elements as extra parameter in collection js events #380

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Resources/js/bc-bootstrap-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@
newWidget = newWidget.replace(/__id__/g, newName[1].replace(re, count));
var newLi = $('<li></li>').html(newWidget);
newLi.appendTo(list);
$this.trigger('bc-collection-field-added');
$this.trigger('bc-collection-field-added', [newLi, collection]);
};

CollectionRemove.prototype.removeField = function (e) {
var $this = $(this),
li = $this.closest('li'),
selector = $this.attr('data-field')
;

e && e.preventDefault();

$this.trigger('bc-collection-field-removed');
var listElement = $this.closest('li').remove();
}
$this.trigger('bc-collection-field-removed', [li]);
var listElement = li.remove();
};


/* COLLECTION PLUGIN DEFINITION
Expand All @@ -86,7 +87,7 @@
};

$.fn.removeField = function (option) {
return this.each(function() {
return this.each(function () {
var $this = $(this),
data = $this.data('removefield')
;
Expand All @@ -109,11 +110,11 @@
$.fn.addField.noConflict = function () {
$.fn.addField = oldAdd;
return this;
}
};
$.fn.removeField.noConflict = function () {
$.fn.removeField = oldRemove;
return this;
}
};


/* COLLECTION DATA-API
Expand All @@ -122,5 +123,4 @@
$(document).on('click.addfield.data-api', addField, CollectionAdd.prototype.addField);
$(document).on('click.removefield.data-api', removeField, CollectionRemove.prototype.removeField);

}(window.jQuery);

}(window.jQuery);