Hi all ;
i have a classic system to add remove line to a form with to image (i
target them with class name "add" and "remove") this first
fuctionality must be executed with live event .
But whene i remove all my line i should add a new button but the live
event on it not seem to be fired
This is my code :

$('.btn_container img').live('click',function(){
        var elementInQuestion           =  $(this).parents
('div.to_duplicate:first') ;
        var contentToInsert             =  elementInQuestion.clone() ;
        var elementInQuestionParent =  elementInQuestion.parents
('li:first') ;

        switch($(this).attr('class')){
                case 'add' :
                        //duplicate the element
                        var duplicated = 
elementInQuestion.before(contentToInsert).hide() ;
                        duplicated.fadeIn() ;
                        //Remove the label (Not a real remove)
                        $('label', duplicated).html(' ') ;
                break ;
                case 'remove' :
                        elementInQuestion.remove() ;
                break ;
        }

        if(elementInQuestion.is('.exploitation_seat')){
                //This code add a span button to add automaticly a
line whene all removed
                if($('div.exploitation_seat').length == 0){

                        
elementInQuestionParent.append('<label>&nbsp;</label><span
class="addIfEmpty">+Add blank</span>') ;
                        //Here the issue whene i click on the span the event 
not fired
                        $('.exploitation_seat span.addIfEmpty').live('click', 
function(){
                                elementInQuestionParent.append(contentToInsert) 
;
                        })
                }
                $('div.exploitation_seat').each(function(i){
                        $(":input", $(this)).each(function () {
                $(this).attr('name', $(this).attr('name').replace(/
[0-9]/g, i)) ;
                $(this).attr('id', $(this).attr('id').replace(/[0-9]/
g,     i)) ;
             })
             $("label", $(this)).each(function () {
                $(this).attr('for', $(this).attr('for').replace(/[0-9]/
g, i)) ;
             })
                })
        }
})
Sorry if the code is long .
Cordialy Ahmed .

Reply via email to