problem with calling dialog('close') on a button within the dialog
Hello,
I have a dialog with an anchor tag inside of it that I want to use to run some jquery when the user clicks on it. Specifically, I want to close the dialog and show a popup for a few seconds letting the user know that their password was reset. The dialog looks like this:
- <div data-role="page" data-dialog="true" id="page-reset-password">
- ***content here***
- <a href="#" id="btn-reset-password" class="ui=btn">Reset Password</a>
- </div>
I can't seem to figure out the correct event to bind the 'click' event to so that the click event doesn't register until the dialog is initiated. For instance, I have tried the js below:
- $(function() {
- $("#page-reset-password").on("pagecreate", function() {
- $("#btn-reset-password").on("click", function() {
- $("#page-reset-password").dialog("close");
- });
- });
- });
No matter what i try, i get the following error:
Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'
Would anybody be able to tell me what I am doing wrong here? thank you very much in advance for any advice that you can provide.