# HG changeset patch # User veltr # Date 1372689107 -7200 # Node ID dd0e7cded39d7fda60e013af42a9ef43d805123a # Parent fdc817dc75c09f4d44231dfaa5c23bfc53f70fc5 Ajax form handling diff -r fdc817dc75c0 -r dd0e7cded39d src/egonomy/static/egonomy/js/main.js --- a/src/egonomy/static/egonomy/js/main.js Fri Jun 28 16:39:45 2013 +0200 +++ b/src/egonomy/static/egonomy/js/main.js Mon Jul 01 16:31:47 2013 +0200 @@ -53,12 +53,33 @@ $('.additemtocollection').bind('click', function(e){ // When an item meant to be added to a collection is clicked, // we fill the form in the add-to-collection div - console.log(this + ", " + $(this) + ", " + $(this).attr('data-type') + ", " + $(this).attr('data-id')); $('#add-to-collection .item-type').val($(this).attr('data-type')); $('#add-to-collection .item-id').val($(this).attr('data-id')); }); + $(".ajax-form").submit(function(e) { // On submit Ajax Form + var formel = $(this); + $.ajax({ + url: formel.attr("action"), + type: formel.attr("method"), + data: formel.serialize(), + success: function() { + $('.popin-wrap').fadeIn(function(){ + $(".additem-success").show(); + }); + console.log.apply(console,arguments); + }, + error: function() { + $('.popin-wrap').fadeIn(function(){ + $(".additem-error").show(); + }); + console.log.apply(console,arguments); + } + }); + formel.parents(".popin").hide(); + return false; + }); if($('#map').length){ initmap() diff -r fdc817dc75c0 -r dd0e7cded39d src/egonomy/templates/egonomy_newbase.html --- a/src/egonomy/templates/egonomy_newbase.html Fri Jun 28 16:39:45 2013 +0200 +++ b/src/egonomy/templates/egonomy_newbase.html Mon Jul 01 16:31:47 2013 +0200 @@ -29,7 +29,7 @@
-
+

+
+

{% trans "The item was successfully added to the collection" %}

+
+
+

{% trans "An error occurred while addin the item to the collection" %}

+
{% endif %} {% block popins %}{% endblock %}