/** * Created by dev on 07.09.2015. */ $(document).ready(function () { $('select').select2({ width: 'element', allowClear: true }); $('#id_country').change(function () { $.get( "/admin/ajax_city/", {'id': $(this).val()}, function (j) { $('#id_city').html(j); $('#id_city').attr('disabled', false); }); }); $('#id_city').select2({ placeholder: "Город", width: 300, ajax: { url: "/admin/city/search/", dataType: "json", quietMillis: 200, data: function (term, page, country) { var country = $('#id_country').val(); return { term: term, page: page, country: country }; }, results: function (data) { var results = []; $.each(data, function (index, item) { results.push({ id: item.id, text: item.label }); }); return {results: results}; } }, initSelection: function (element, callback) { var id = $(element).val(); var text = $(element).attr('data-init-text'); callback({id: id, text: text}); } }); // displaying uploaded photo function handleFileSelect(evt) { var files = evt.target.files; // FileList object // Loop through the FileList and render image files as thumbnails. for (var i = 0, f; f = files[i]; i++) { // Only process image files. if (!f.type.match('image.*')) { continue; } var reader = new FileReader(); // Closure to capture the file information. reader.onload = (function (theFile) { return function (e) { document.getElementById('list').innerHTML = [''].join(''); }; })(f); // Read in the image file as a data URL. reader.readAsDataURL(f); } } document.getElementById('id_photo').addEventListener('change', handleFileSelect, false); document.getElementById('id_logo').addEventListener('change', handleFileSelect, false); console.log("hello from new specialist view.js"); });