app/assets/javascripts/jqr-helpers.js in jqr-helpers-1.0.21 vs app/assets/javascripts/jqr-helpers.js in jqr-helpers-1.0.22

- old
+ new

@@ -26,12 +26,18 @@ $('.ui-dialog:visible form').first().submit(); } // called from dialog button value function ujsDialogClose() { - $('.ui-dialog-content:visible').dialog('destroy') - .addClass('ujs-dialog-hidden'); + $('.ui-dialog-content:visible').each(function() { + if ($(this).data('remote-dialog')) { + $(this).dialog('destroy').remove(); + } + else { + $(this).dialog('destroy').addClass('ujs-dialog-hidden'); + } + }); } function ujsDialogOpen() { $(this).css('maxHeight', ($(window).height() * 0.8) + 'px'); if ($(this).parent().height() > $(window).height()) { @@ -108,10 +114,11 @@ var closeX = $(this).data('close-x'); if (dialogElement.length == 0) { $('body').append("<div id='" + dialogID + "'>"); dialogElement = $('#' + dialogID); } + dialogElement.data('remote-dialog', true); dialogElement.load(url, function() { if (closeX) { dialogElement.prepend('<span class="ujs-dialog-x"></span>'); } if (dialogElement.find('.ujs-dialog-title-hidden').length) { @@ -143,10 +150,11 @@ } function ujsButtonClick(event) { var element = $(this); element.uniqueId(); // to store for later - if ($.rails.allowAction(element)) { + // if the button is inside a form, allowAction is already called. + if ($(this).closest('form').length || $.rails.allowAction(element)) { element.data('confirm', null); // we've already fired it // largely copied from rails_jquery.js var href = element.data('url'); var method = element.data('method'); var csrf_token = $('meta[name=csrf-token]').attr('content');