Hi guys. I hope you can help me with my little problem with jQuery.

I'd like to do something like this:

After the page is loaded I have some forms with submit buttons. The
buttons have a class called "open". By clicking any of these buttons
the script is using AJAX to take some data from database and add some
HTML to the document. This part of generated HTML has also buttons
with a class "open". By clicking any of the new buttons script should
do what it does with the old ones. The problem is I have no idea how
to "refresh" a click function. After generating HTML it "sees" only
the old buttons.

Here's some code:

$(document).ready(function(){
        $(".open").click(function(){
                var idVal = $(this).parent().parent().find("#PlaceId").val();
                if($("#admin_places_"+idVal).html()=='')
                {
                        $(this).attr('value', 'Zwiń >>');
                        $.post("/places/open/"+idVal, null ,
                                                function(data){
                                $("#admin_places_"+idVal).html(data);
                                                }
                                 );
                }
                else
                {
                        $("#admin_places_"+idVal).html('');
                        $(this).attr('value', 'Rozwiń >>');
                }
                return false;
        });
});

Thanks in advance for helping me.

Reply via email to