Sunday, 15 August 2010

backbone.js - UI hash problems with Backbone Marionette Layout -



backbone.js - UI hash problems with Backbone Marionette Layout -

in next layout, adding collectionview display select list within onrender. after that, using ui hash enable or disable controls within view. not work select generated new app.view.categories.

should it? or ui hash not work on regions within layout?

app.view.uploadfile = backbone.marionette.layout.extend({ template: '#upload-file-template', regions:{ category: 'td:nth-child(4)' }, ui:{ inputs: 'textarea, select, .save' }, onrender: function(){ this.category.show( new app.view.categories({ collection: app.collection.categories }) // generates select list ); console.log(this.ui.inputs); // length 2. missing select. console.log(this.$('textarea, select, .save')); // length 3 this.ui.inputs.prop( 'disabled', (this.model.get('upload_status')!='staged') ); } });

this should working way expect work. code in question in marionette source here: https://github.com/marionettejs/backbone.marionette/blob/master/src/marionette.itemview.js#l49-l51

the phone call binduielements() converts ui hash in jquery selector objects, , called right before onrender method called.

are seeing errors? or selector returning nothing, , having no impact on elements?

update:

ah! of course... wasn't paying attending code close enough. you're right in ui element selectors happen before you're adding the sub-view region. i've never run in situation before... seems want prepare / support.

for now, best workaround can suggest phone call 'this.binduielements();' @ end of onrender method. forcefulness ui elements re-bind selectors.

i'll add together issue github issues list, in improve solution this. don't know when i'll able this, @ to the lowest degree on list of things fix.

backbone.js marionette

No comments:

Post a Comment