From 818c70198e3e1f06947c35d1e5af3279989e115d Mon Sep 17 00:00:00 2001 From: Andrey A.I. Sitnik Date: Thu, 18 Nov 2010 23:13:55 +0300 Subject: [PATCH] Prevent double clicking on a[data-method] --- src/rails.js | 6 ++++++ test/public/test/data-method-iframe.js | 5 ++++- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/src/rails.js b/src/rails.js index 427e0c2..e178660 100644 --- a/src/rails.js +++ b/src/rails.js @@ -108,6 +108,12 @@ jQuery(function ($) { form = $('
'), metadata_input = ''; + if (link.data('rails.submiting')) { + e.preventDefault(); + return; + } + link.data('rails.submiting', true); + if (csrf_param !== undefined && csrf_token !== undefined) { metadata_input += ''; } diff --git a/test/public/test/data-method-iframe.js b/test/public/test/data-method-iframe.js index 06dcd12..27eba12 100644 --- a/test/public/test/data-method-iframe.js +++ b/test/public/test/data-method-iframe.js @@ -13,12 +13,15 @@ module('data-remote-iframe', { } }); -test('clicking on a link with data-method attribute', function() { +test('double clicking on a link with data-method attribute', function() { expect(0); stop(); $('a[data-method]') .trigger('click'); + + $('a[data-method]').attr('href', App.url('update')) + .trigger('click'); App.timeout(); }); -- 1.7.1