I have an event firing which executes 'this.render' in an ItemView. This line of code is definitely run.
However neither the onBeforeRender nor the onRender events are fired.
They are fired when the View is shown into a region.
Is this expected behaviour?
Thanks
--Justin Wyllie
Sorry. Minor bug. this.render(). Duh!
Related
I'm working on improving performance of ng application. I've meet with strange side effect of FastClick.
It leads to multiple dispatch Events (see attached image) and to a row of $digest which I would prefer to avoid.
Does anybody know how to cope with such behavior?
Actually it wasn't "fast click" issue.
It was partially my mistake.
I had a few ng-click handlers that is fired during the event bubbling, and angular-touch ways to $digest on every node element that have ng-click event listener.
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.
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
Or does it fire another unique event?
Any input on how else could I have figured this out on my own (other then searching stackoverflow and reading bb documentation) is welcome. 10x.
Collection.update doesn't seem to fire any special events. add and remove events are fired for added and removed models, respectively.
The best way to find out how Backbone works is to read the annotated backbone source code.
I have this situation:
<Button MouseDown="Button_MouseDown" Click="Button_Click">
<TextBlock MouseDown="Inner_MouseDown">Button</TextBlock>
</Button>
Method Inner_MouseDown is completely empty. .Handled is NOT set to true.
But Button_Click is not executed. If I remove the MouseDown="Inner_MouseDown",button clicks without problems. Can anybody help me find out why handling MouseDown with no logic prevents button from click?
Thanks a lot.
Andrej
OK, I found out something important. It seems that it works good until I add breakpoint to Inner_MouseDown method. If debugger stops there Click event is not raised. If I just remove the breakpoint it works allright. Same problem if I show messagebox in the Inner_MouseDown method. If I just increment some temp variable it works nice.
But this answers my question, why it does not work even if it should. Actually it works, problem is somewhere else.
My guess: It may be because Click == MouseDown + MouseUp within a small time interval, and when you break after the MouseDown, the MouseUp isn't processed until after the time interval has elapsed.
In my surface application I have a SurfaceWindow with a SurfaceUserControl on. On the SurfaceUserControl I have a SurfaceButton but the ContactUp (and down) event is not fired. The ContactHoldGesture event is fired though.
Any ideas?
Could you include some code to reproduce? Where are you subscribing to those events?
Most likely what's happening is the contact up and down events are being handled by the button, so they don't fire at the usercontrol level. Try looking at the previewcontactup and previewcontactdown events.
ContactUp and ContactDown are handled by the button itself - that's why the events never get to your code. If you really want to intercept these events, use PreviewContactUp/PreviewContactDown instead. What you probably really need though is to just handle the Click event on the button. Adjust the ClickMode property of the button if you want to change what causes the Click event to be raised.