Live events are probably what you're looking for. They allow you to
bind events to dom nodes that don't exist yet.

http://docs.jquery.com/Events/live

However they don't work for change.. you would have to refactor your
code a bit to use 'click'

On May 7, 7:00 am, vmoravek <vojtech.mora...@googlemail.com> wrote:
> Hi All,
> I would like to ask you for help with some behavior with replace DIV
> content. I understood why it happens but I don’t know or I don’t
> clearly understood how I can fight against.
>
> When I use ajax jquery call $load and replace DIV with new html
> content I lost DOM binding for new html elements.
>
> I read some articles on internet or on docs.jquery.com and  found why.
> Because new DIV content was load after all page is loaded so I must
> somehow ”register”  new elements into DOM structure, and also i did
> found manual how solve my trouble 
> onhttp://docs.jquery.com/Frequently_Asked_Questions#Why_do_..._.3F,
> but doing something wrong and cannot write right jquery code :(
>
> My example:
> I have html user registration form with many INPUT:TEXT fields like
> “username” “address”, “email” etc.. When change event is detected on
> any of those fields, validation process is call by AJAX request and
> return html code. Everything work fine but only once. Please, could
> you look on my code and tell me how I can rebind new INPUT:TEXT fields
> to DOM structure.
>
> $(document).ready(function(){
>
> $("input:text").change(function() {
>
> //POST values
>                         var postdata = {};
>
>                         postdata["name"]              = $(this).attr("name");;
>                         postdata[$.input_name]  = $(this).val();;
>
>         //Send AJAX request
>
>               div_name =  ".reg_field_" + $(this).attr("name");
>                 $(div_name).load("/test/index.php &ajax=true",postdata)
>         });
>
> });

Reply via email to