UI hash issues with breadboard mast layout

In the next Layout , I add a CollectionView to display the SELECT list in onRender . Immediately after that, I use the ui hash to enable or disable all controls in the view. This does not work for SELECT generated using new App.View.Categories .

Should it? Or does the 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 the 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') ); } }); 
+6
source share
1 answer

This should work the way you expect it to work. The code provided by the Marionette source is here: https://github.com/marionettejs/backbone.marionette/blob/master/src/marionette.itemview.js#L49-L51

The bindUIElements() call is what converts the ui hash to jQuery selector objects and is called just before the onRender method is onRender .

Do you see errors? Or does the selector simply return nothing and not affect the elements?


Update:

Oh! Of course ... I didn't pay attention to your code close enough. You are right that the user interface element selector happens before you add a subtask to a region. I have never encountered this situation before ... but it seems like we would like to fix / support.

Currently, the best solution I can offer would be to call this.bindUIElements (); at the very end of your onRender method. This will cause ui elements to re-bind to selectors.

I will also add the problem to the github problem list to find the best solution for this. I don’t know when I can get to this, but at least it will be on the list of things that need to be fixed.

+11
source

All Articles