Marionette onShow not firing after rerender region view

I have a region, and I need to execute some code once the view is rendered. So the first time I call myRegion.show(myView)The code that goes inside onShow in myView does the work.

The same piece of code doesn't work onRender or at initialize. The problem comes, when after a change in myView I call this.render() to reflect the changes. This time, "onShow" is not firing.

I think that I can trigger an event from the view, catch it at the parent view and call again to myRegion.show(myView). But it looks like a tricky solution, and I don't know if there could be a better way to manage this situation.

Answers


onShow callback is called only once when you insert your view into the region.

I think in your case you should use onDomRefresh. Marionette calls it when view is showed into region and when it is re-rendered (but only when it is showed already). So you can make all your DOM dependent code in it.

You can read more in docs: https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.view.md#view-domrefresh--ondomrefresh-event


Need Your Help

Stream smartphone display to laptop wirelessly

stream smartphone vrone

I'm creating an app in Unity with the VR One SDK and I was wondering how I could stream the display from my phone(galaxy samsung S5) to my laptop wirelessly

overriding bundler's release, but without putting it in the gem

ruby bundler geminabox

I'm using bundler to manage my gem's dependencies, and I'm using geminabox to host my gems once they're ready. Using bundler's rake release is bad news, because my gems will go to rubygems, not to