I can not manipulate / select loaded divs via an Ajax call?


I've a simple application, and I decided to use ajax to load levels for simplicity / whatever reason (maybe to learn a bit).

But I'm stuck...

    url: "actions.php",
    get: "GET",
    data: "show_level=" + 1,
    cache: false,
    success: function (views){

The problem is, views appended to my container is not selectable anymore, basically all jquery functions I had stopped working alltogether.

What is happening?

If you are using bindings like $(".target-element").click(function(){ do something here}); they are only valid for elements already in the DOM when the binding happens.

You would need to use $("#element-already-in-dom").on("click", ".target-element", function(){do something here});