I may not have correctly understood your question, but you cannot use the warning function to display a message inside a page element. Alert displays a system warning outside the dom page.
If you want to display the message inside the modal code, you must enable (or enter) the modal markup on the html page, then you just show / hide the modal functions using the bootstrap functions.
You have a very good example here.
source share