-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.js.erb
39 lines (33 loc) · 1.75 KB
/
create.js.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var from = "<%= @from %>";
if (from == 'first_list') {
console.log("from page " + from);
$("#movie_modal_innard_<%= @movie.tmdb_id %>").html("<%= j(render partial: 'movies/movie_modal_innard', locals: {movie: @movie}) %>");
$("#movie_show_listings_<%= @movie.tmdb_id %>").html("<%= j(render partial: 'movies/movie_show_list_manage', locals: {movie: @movie}) %>");
}
else {
$("#movie_on_lists_<%= @movie.tmdb_id %>").html("<%= j(render partial: 'movies/movie_on_lists', locals: {movie: @movie}) %>");
$("#movie_other_list_<%= @movie.tmdb_id %>").html("<%= j(render partial: 'movies/movie_add_to_another_list', locals: {movie: @movie}) %>");
$("#movie_show_listings_<%= @movie.tmdb_id %>").html("<%= j(render partial: 'movies/movie_show_list_manage', locals: {movie: @movie}) %>");
}
<%# On a list view, we need to specify the movie
so we use the movie's tmdb_id %>
var $listPageDropdown = $("#myModal_<%= @movie.tmdb_id %>").find("#add-to-list-dropdown-" + "<%= @movie.tmdb_id %>");
($listPageDropdown).click(triggerClickForListAutocomplete);
($listPageDropdown).autocomplete({
source: $listPageDropdown.data('autocomplete-source'),
minLength: 0,
select: function(event, ui) {
handleAddToListAutocompleteSelect($listPageDropdown, ui)
}
});
<%# On a show page, we have only one movie,
but we still need the selector because the class is on _all_ movies %>
var $showPageDropdown = $("#movie_show_listings_" + "<%= @movie.tmdb_id %>").find("#add-to-list-dropdown-" + "<%= @movie.tmdb_id %>");
($showPageDropdown).click(triggerClickForListAutocomplete);
($showPageDropdown).autocomplete({
source: $showPageDropdown.data('autocomplete-source'),
minLength: 0,
select: function(event, ui) {
handleAddToListAutocompleteSelect($showPageDropdown, ui)
}
});