Django: Add animation to “task” divs, and also trouble with some CSS

前端 未结 1 1640
余生分开走
余生分开走 2021-01-26 22:58

I\'m a newbie to web development with regards to using a server and jQuery. What I\'m creating as an assignment to learning Django before I do my big employment project is simpl

1条回答
  •  北海茫月
    2021-01-26 23:47

    The thing to understand is that load, which is an Ajax call, is asynchronous. That means that the Javascript continues executing while the request is being made. In order to do something when the call completes, you pass a callback function as a parameter to load. jQuery automatically calls that function when the Ajax is finished loading.

    $("#listOfThingsToDo").load(document.URL + ' #listOfThingsToDo', function() {
            $(".checkbox-task:last").hide();
            $(".checkbox-task:last").fadeIn(500);
    });
    

    You can see that the hide and fadeIn calls are within the anonymous function, so they will only be executed when the Ajax request is complete.

    0 讨论(0)
提交回复
热议问题