Browse Source

Improved pin form to use post's incoming data on successful submission to auto-prepend to the list

tags/v1.0.0
Isaac Bythewood 11 years ago
parent
commit
7fe3769248
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      pinry/static/js/pin-form.js

+ 5
- 3
pinry/static/js/pin-form.js View File

@@ -9,7 +9,6 @@




$(window).load(function() { $(window).load(function() {
var currentPin;
// Start Helper Functions // Start Helper Functions
function getFormData() { function getFormData() {
return { return {
@@ -68,6 +67,8 @@ $(window).load(function() {
} }
$('#pin-form-submit').click(function(e) { $('#pin-form-submit').click(function(e) {
e.preventDefault(); e.preventDefault();
$(this).off('click');
$(this).addClass('disabled');
var data = { var data = {
submitter: '/api/v1/user/'+currentUser.id+'/', submitter: '/api/v1/user/'+currentUser.id+'/',
url: $('#pin-form-image-url').val(), url: $('#pin-form-image-url').val(),
@@ -75,9 +76,10 @@ $(window).load(function() {
tags: cleanTags($('#pin-form-tags').val()) tags: cleanTags($('#pin-form-tags').val())
}, },
promise = postPinData(data); promise = postPinData(data);
promise.success(function() {
promise.success(function(pin) {
if (pinFromUrl) return window.close(); if (pinFromUrl) return window.close();
$('#pins').prepend(currentPin);
pin = renderTemplate('#pins-template', {pins: [pin]});
$('#pins').prepend(pin);
dismissModal(modal); dismissModal(modal);
}); });




Loading…
Cancel
Save