I'm using alert()
to output my validation errors back to the user as my design does not make provision for anything else, but I would rather use jQuery UI dialog as the alert dialog box for my message.
Since errors are not contained in a (html) div, I am not sure how to go about doing this. Normally you would assign the dialog()
to a div say $("#divName").dialog()
but I more need a js function something like alert_dialog("Custom message here")
or something similiar.
Any ideas?
Just throw an empty, hidden div onto your html page and give it an ID. Then you can use that for your jQuery UI dialog. You can populate the text just like you normally would with any jquery call.
Use this code syntax.
this works but it append a node to the DOM. You can use a class and then or first remove all elements with that class. ex:
There is an issue that if you close the dialog it will execute the onCloseCallback function. This is a better design.