I have custom JS firing to run a simple select2() (jQuery extension) for selects. I've put it many places in my detail.js (edit view, after-edit change, etc) but it doesn't run until I look at the Edit screen at least once. How do i get it to consistently fire from the first time out? I understand for things like button clicks I can use .on functionality to prevent a race condition or whatever is happening, but how do I do this for this? I'm sure it is an event I am overlooking (I hope anyway).
this.on('after:render', function () {
this.$detailButtonContainer = this.$el.find('.detail-button-container');
this.$dropdownItemListButton = this.$detailButtonContainer.find('.dropdown-item-list-button');
// this only fires after the first line
this.$el.find('select.form-control.main-element').select2();
}, this);
this.on('after:render', function () {
this.$detailButtonContainer = this.$el.find('.detail-button-container');
this.$dropdownItemListButton = this.$detailButtonContainer.find('.dropdown-item-list-button');
// this only fires after the first line
this.$el.find('select.form-control.main-element').select2();
}, this);
Comment