Creating and deleting items, using live()
I have some ajax functionality I have made, this basically creates an item in a database by an add button, the items are in a li.
I have a delete button span which when pressed shows a confirm or cancel buttons which are hidden initially, If i have more than one item in the list is will show and hide them on all the items in the list, heres the code
- $('.source_delete').live('click', function(){
-
- //Fade out delete button
- $('.source_delete').fadeOut();
- //Show confirm button
- $('.source_delete_confirm').fadeIn();
-
- //If cancel remove confirm and show delete buttin again
- $('.source_delete_confirm a.cancel_delete').live('click', function(){
- $('.source_delete_confirm').fadeOut();
- $('.source_delete').fadeIn();
- });
-
- $('.source_delete_confirm a.confirm_delete').live('click', function(){
- // Get ID value & this object
- var source_id = $(this).siblings(':first').attr('id');
-
- // Url to send data to
- var ajax_base_url = '../../../wolf/admin/bespoke_scripts/retire_source.php';
-
- // Data array to be sent
- var submit_data = {};
- submit_data['id'] = source_id;
-
- // Set success callback function
- var callback_success_function = function(ajax_return,calling_obj){
-
- $(calling_obj).parent().fadeOut(2000);
-
- }
- // Set ajax vars
- var std_ajax_options = ajax_options(ajax_base_url,submit_data,callback_success_function,this);
-
- // Complete ajax operation
- $.ajax(std_ajax_options);
-
- return false;
-
- });
- });
I need the show and hide not to apply to all items in list, the issue is im aware you cannot use live and each together, is this correct?? how can I go about doing this?