JQuery and .load () events

Never encountered this problem with jQuery before. I have the following:

$(document).ready(function() {
    $('#browser_cat a').click( function() {
        $('#browser_cat').hide();
        $('#browser_cat').load('/api/browser/catchildren/'+$(this).attr('id'));
        $('#browser_cat').fadeIn();
        return(false);
    })
});

Pretty simple stuff. And it works, however, the data collected .load()does not restart the event. This is a type of drillthrough category type ... so that level-1 does the workload and then leve-2 is freed from it hrefinstead of firing the event again click().

The loaded HTML is #browser_catwith links, and the generated DOM is fine.

I argue that this is elementary. Thanks in advance.


Response to the modified code:

$(document).ready(function() {
    $('#browser_cat a').live("click", function() {
        $('#browser_cat').hide();
        $('#browser_cat').load('/api/browser/catchildren/'+$(this).attr('id'));
        $('#browser_cat').fadeIn();
        return(false);
    })
});
+3
source share
1 answer

Use live event

, , .

$('#browser_cat a').click( function() {

$('#browser_cat a').live("click", function() {
+5

Source: https://habr.com/ru/post/1735171/


All Articles