Adds onAttach triggerMethod.

Adds `triggerAttach` and `beforeTriggerAttach` triggerMethods.

This is the 3rd out of 3 PRs to get #1886 in.
If `triggerBeforeAttach` and `triggerAttach` are true (which will be the common case), then we can reuse the `displayedViews` array obtained above (avoiding calling `_getNestedViews` again)