Trying to figure out the reference on a dialog called with AJAX data.
Here's the code:
- $.ajax({
- type: 'GET',
- url: url,
- dataType: 'json',
- success: function(data){
- $(data.html).dialog({
- autoOpen: false,
- title: 'Sign In',
- modal: true,
- dialogClass: 'login-form-dialog'
- });
- $(this).dialog('open');
- },
- error: function (xhr, ajaxOptions, thrownError){
- alert(xhr.statusText);
- alert(thrownError);
- }
- });
Basically, on my page the user clicks a link, which pulls in the HTML for the form via JSON, which I then use to open the dialog. If I create this dialog without autoOpen: false, it works just as intended - however I can't hide/destroy the dialog except by hitting the (x). Calling
- $('.login-form-dialog').dialog('close');
Doesn't kill the dialog. I've tried other permutations, like '.ui-dialog' and a plain-ol 'this', as you can see.
Since the dialog is being constructed with the ajax data - how do I refer to it from then on?