javascript - backbone.js - How to get rid of div? - how to render option? -
i need render select backbone.js. injects wrapper div?
trying set tagname: ''
not allowed.
var muppetslistitemview = backbone.view.extend({ tagname: '',//leads error render: function() { this.$el.html('<option id="'+this.model.get('id')+'">'+this.model.get('key')+'</option>'); return this; },
if want handle html completly on own, how can achieve this, without backbone interfering , adding div?
or alternatively, if can explain how renderd backbone injecting arbitrary attributes <option>
tag when setting tag tagname:
, great. (what mean is, have backbone injects id , key in html above "automatically" in option tag (but not using templating system)). thanks!
you want use view.attributes
id
, use templates setting content of option normal.
http://backbonejs.org/#view-attributes http://backbonejs.org/#view-template
var muppetslistitemview = backbone.view.extend({ tagname: 'option', attributes: function() { return { id: this.model.get('id'), }; }, ...
if unfamiliar using templates backbone views, here guide: http://codebeerstartups.com/2012/12/how-to-use-templates-in-backbone-js-learning-backbone-js/
Comments
Post a Comment