|
- $("body").append("<%= j render partial: "admins/unit_applies/shared/edit_modal",locals: {apply: @unit_apply, schools: @all_schools} %>")
- var uni_edit_modal = $(".admin-unit-edit-modal")
- uni_edit_modal.modal("show")
-
- uni_edit_modal.on("hidden.bs.modal",function () {
- $(".admin-unit-edit-modal").remove()
- $("body").removeClass("modal-open")
- })
-
- // 初始化学校选择器
- var matcherFunc = function(params, data){
- if ($.trim(params.term) === '') {
- return data;
- }
- if (typeof data.text === 'undefined') {
- return null;
- }
- if (data.name && data.name.indexOf(params.term) > -1) {
- var modifiedData = $.extend({}, data, true);
- return modifiedData;
- }
-
- // Return `null` if the term should not be displayed
- return null;
- }
- $.ajax({
- url: '/api/schools/for_option.json',
- dataType: 'json',
- type: 'GET',
- success: function(data) {
- $("#all-schools").select2({
- theme: 'bootstrap4',
- placeholder: '查询学校/单位',
- minimumInputLength: 1,
- data: data.schools,
- templateResult: function (item) {
- if(!item.id || item.id === '') return item.text;
- return item.name;
- },
- templateSelection: function(item){
- return item.name || item.text;
- },
- matcher: matcherFunc
- })
- }
- });
-
- $("#all-schools").select2({})
- $("#show-province-<%= @unit_apply.id %>").select2()
- $("#schoolCity_<%= @unit_apply.id %>").select2()
-
- // **************** 地区选择 ****************
- $('.province-city-select').cxSelect({
- url: '/javascripts/educoder/province-data.json',
- selects: ['province-select', 'city-select']
- });
|