Fragments are wide used for Dialogs. So, here you have an example to create a Dialog without the XML, just JavaScript.
You can use it as a model/reference for your need, just adapt it.
https://openui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.Dialog/code/C.controller.js
Hope it help you.