Skip to content

Commit

Permalink
Refactored so that we only retrieve the feature files content if the …
Browse files Browse the repository at this point in the history
…content is not already on the page.
  • Loading branch information
baphled committed Jul 6, 2010
1 parent 8c6dd3f commit bd13f9c
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions public/javascripts/jquery.ajax.dialog.js
Expand Up @@ -12,27 +12,32 @@ $(function() {

// bind click event to related property on page
$('a#file-feature').live('click', function() {
// make ajax call
$.ajax({
url: $('a#file-feature').attr('href'),
type: 'GET',
dataType: 'html',
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
// populate dialog box with content
$dialog
.append(data)
.dialog({
title: 'Source feature content',
width: '75%',
buttons: { "Ok": function() { $(this).dialog("close"); } }
});
},
error: function(xhr, textStatus, errorThrown) {
// display flash error
}
});
// check to see if we already have the dialog element on the page
if ($('div pre').size() == 0) {
// make ajax call
$.ajax({
url: $('a#file-feature').attr('href'),
type: 'GET',
dataType: 'html',
complete: function(xhr, textStatus) {
},
success: function(data, textStatus, xhr) {
// populate dialog box with content
$dialog
.append(data)
.dialog({
title: 'Source feature content',
width: '75%',
buttons: { "Ok": function() { $(this).dialog("close"); } }
});
},
error: function(xhr, textStatus, errorThrown) {
// display flash error
}
});
} else {
$('div.dialog').dialog('open');
}

return false;
})
Expand Down

0 comments on commit bd13f9c

Please sign in to comment.