I"• (function() { var PageModuleEditSubjectForm, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; PageModuleEditSubjectForm = (function() { function PageModuleEditSubjectForm() { this.search_posts = bind(this.search_posts, this); this.init_multiselect = bind(this.init_multiselect, this); this.init_multiselect(); this.post_select = $('#page-module-subject-select'); this.subject_id_input = $("#page_module_subject_id"); this.clear_link = $(".js-clear-page-module-subject"); this.post_select.autocomplete({ source: (function(_this) { return function(request, response) { return $.get(_this.post_select.attr("data-autocomplete-uri"), { term: request.term }, function(resp) { var data, i, item, len, ref; data = []; ref = resp.posts; for (i = 0, len = ref.length; i < len; i++) { item = ref[i]; data.push({ label: item.label, value: item.label, subject_id: item.value }); } return response(data); }); }; })(this), select: (function(_this) { return function(event, ui) { return _this.subject_id_input.val(ui.item.subject_id); }; })(this) }); this.clear_link.click((function(_this) { return function(e) { e.preventDefault(); _this.post_select.val(""); return _this.subject_id_input.val(""); }; })(this)); } PageModuleEditSubjectForm.prototype.init_multiselect = function() { this.post_multiselect = $('.js-post-multiselect'); return this.post_multiselect.multiselect({ searchFunc: this.search_posts }); }; PageModuleEditSubjectForm.prototype.search_posts = function(term, callback) { if (term !== "") { return $.get(this.post_multiselect.attr("data-autocomplete-uri"), { term: term }, (function(_this) { return function(response) { return callback([response.posts]); }; })(this)); } else { return callback([null]); } }; return PageModuleEditSubjectForm; })(); window.PageModuleEditSubjectForm = PageModuleEditSubjectForm; }).call(this); :ET