![]() |
[solved] Ajax cart updating - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: [solved] Ajax cart updating (/showthread.php?tid=43469) |
[solved] Ajax cart updating - El Forum - 07-12-2011 [eluser]umbungo[/eluser] I have a (working) form to update my cart as; Code: //form open, id=cart_update I am trying to add ajax functionality. When adding items I had an add button and form for each item, and the following worked great (Jquery); Code: $("form.add").submit(function() { But i'm not sure how to work with multiple items here.. I can't do something like add a hidden form (name='id', id=$id) because it would just be overwritten and always point to the last item. ?? I'm also not sure how to get a value of an item which is part of an array.. I attempted to retreive the values from the forms (as top) by setting a test value for 'id' in the JS, but the following still didn't work; Code: var id = '1234'; [solved] Ajax cart updating - El Forum - 07-12-2011 [eluser]Eric Barnes[/eluser] Why not just pass all the form values? Code: var data = $("form.add").serialize(); [solved] Ajax cart updating - El Forum - 07-13-2011 [eluser]umbungo[/eluser] I think i have found the 'real' problem.. it doesn't work because part of the form is generated by ajax. I have tried Code: $("form#cart_update").submit(function() { Code: $("form#cart_update").live('submit',function(e){ [solved] Ajax cart updating - El Forum - 07-13-2011 [eluser]umbungo[/eluser] Solved it.. the problem was that the <form> and </form> elements were not on the same level of the DOM (along with the use of live). This didn't cause problems with a normal load.. but with an ajax load it did. |