Closed hlcfan closed 10 years ago
insertFields
should return inserted content so you can change your code to:
window.NestedFormEvents.prototype.insertFields = function(content, assoc, link) {
$('table tbody').append(content);
return $(content);
}
will override window.NestedFormEvents.prototype.insertFields
affect listen to nested:fieldAdded
?
I found that when i custom window.NestedFormEvents.prototype.insertFields
, it cannot listen to nested:fieldAdded
.
You can see in https://github.com/ryanb/nested_form/blob/master/vendor/assets/javascripts/jquery_nested_form.js#L51 that insertFields
return value is used to trigger nested:fieldAdded
event.
It means that you might need something like:
window.NestedFormEvents.prototype.insertFields = function(content, assoc, link) {
var target = $('table tbody');
return $(content).appendTo(target);
}
ya, thanks.
chrome console:
Uncaught TypeError: Cannot read property 'trigger' of undefined jquery_nested_form.js?body=1:48