From 7fe3769248a7f10d6ab5a04493a55cd8cde435d5 Mon Sep 17 00:00:00 2001 From: Isaac Bythewood Date: Wed, 27 Feb 2013 08:03:23 +0000 Subject: [PATCH] Improved pin form to use post's incoming data on successful submission to auto-prepend to the list --- pinry/static/js/pin-form.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pinry/static/js/pin-form.js b/pinry/static/js/pin-form.js index 3b3e575..0310486 100644 --- a/pinry/static/js/pin-form.js +++ b/pinry/static/js/pin-form.js @@ -9,7 +9,6 @@ $(window).load(function() { - var currentPin; // Start Helper Functions function getFormData() { return { @@ -68,6 +67,8 @@ $(window).load(function() { } $('#pin-form-submit').click(function(e) { e.preventDefault(); + $(this).off('click'); + $(this).addClass('disabled'); var data = { submitter: '/api/v1/user/'+currentUser.id+'/', url: $('#pin-form-image-url').val(), @@ -75,9 +76,10 @@ $(window).load(function() { tags: cleanTags($('#pin-form-tags').val()) }, promise = postPinData(data); - promise.success(function() { + promise.success(function(pin) { if (pinFromUrl) return window.close(); - $('#pins').prepend(currentPin); + pin = renderTemplate('#pins-template', {pins: [pin]}); + $('#pins').prepend(pin); dismissModal(modal); });