Reputation: 1415
I'd like to wrap a Backbone/Marionette CollectionView in a span tag so I can style a SELECT element.
When I try:
ProductOptionsView: Marionette.CollectionView.extend({
tagName: 'select',
className: 'prod-options',
itemView: self.views.ProductOptionsItemView,
onRender: function() {
var $option = $('<option data-price="' + self.currentBasePrice + '" value="-1">Select an option</option>');
this.$el.attr('id', 'options-select');
this.$el.wrapAll('<span class="sold" /');
<snip~>
The call to wrapAll() doesn't happen. If I could just apply all the styles directly to the select tag, I would, but that's not supported. I can't find anything in Marionette or Backbone docs that show how to modify what HTML is actually output from their views.
Or if it would be possible to set a tagname of 'span' and then build a select with options underneath it, I could possibly do that.
Upvotes: 0
Views: 149
Reputation: 18462
Try onShow
, since onRender
gets called before the view's el
is added to the DOM.
view.el
gets appended to the DOM, so wrapping it in onRender
won't actually do anything.
Upvotes: 2