Skip to content

Instantly share code, notes, and snippets.

@adam8810
Created April 18, 2013 23:28
Show Gist options
  • Save adam8810/5417000 to your computer and use it in GitHub Desktop.
Save adam8810/5417000 to your computer and use it in GitHub Desktop.
Select2 Events
$('#add_to_list').on('change', function($e) {
if ($e.added !== undefined) {
$.ajax({
url: '/api/add_to_list.json',
data: {list_id: $e.added.id, movie_id: $id, user_id: $user_id},
success: function() {
add_notify($movie_title, $e.added.text, $poster);
}
});
}
if ($e.removed !== undefined) {
$.ajax({
url: '/api/remove_from_list.json',
data: {list_id: $e.removed.id, movie_id: $id},
success: function() {
remove_notify($movie_title, $e.removed.text, $poster);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment