Talon
Talon

Reputation: 4995

Making a list sortable even after an Ajax Load

I'm loading a li list like this

$('#knowledgeList').load('file.php#knowledgeList');

However I also need to make the list sortable:

$('#knowledgeList').sortable();

That works if I don't Ajax load the items in but if they are loading in via Ajax they are no longer sortable.

Upvotes: 1

Views: 540

Answers (1)

PlantTheIdea
PlantTheIdea

Reputation: 16359

In order to apply any JavaScript/jQuery to the component called in via AJAX, you need the object you want to manipulate in a callback function.

$('#knowledgeList').load('file.php #knowledgeList',function(){
      $('#knowageList').sortable();
});

Upvotes: 2

Related Questions