jQuery - Form submit
<p>I have a form that I intend to submit using jQuery. The following code works fine for the first time. </p>

<p>If the returning data equals "updated" I re-create the form within my #cart-content element. In other words: If i submit the form and it updates my cart I have a new form on my site (which has the same class, same inputs etc).</p>

<p>If I then click on submit again it wont trigger my jQuery code. I guess that because it's a new form that did not exist when the page was loaded so jQuery is not bound to its events and it doesnt get triggered when I submit the form.</p>

<p>What do I have to change to get it working? Thanks in advance!</p>

<pre><code>$("form.update-cart").on("submit", function(event){
        $.post(link + "create_order/update_cart",  $(this).serialize(),  
        function(data){  
            if(data == 'updated')
            {
                var csrf_cookie = $.cookie('csrf_cookie_name');
                $("#cart-content").load(link + "create_order/display_cart", {"csrf_test_name": csrf_cookie});
            }
            else if(data == 'nothing-to-update')
            {
                return false;
            }
            else
            {  
                alert("Couldnt update cart!");  
            }  
        });  
        return false; 
});
</code></pre>
