I came across the same problem as described here.
Getting the element in onShow callback to show/activate a modal won't work if doInsert is placed after the callback.
Changing the order seems to work.