diff options
author | Sashi20 | 2020-02-20 12:58:59 +0530 |
---|---|---|
committer | Sashi20 | 2020-02-20 12:58:59 +0530 |
commit | 1fb3d381e832d5c5871c6cb2fd8b2c1ae3dbd029 (patch) | |
tree | 3a9829196102efdf509fe50b5458237966999ecf /arduino_blog/static/admin/js/autocomplete.js | |
parent | 802bbc270363d1432cb28cd88d6c9003d8b99b6c (diff) | |
download | arduino_projects_website-1fb3d381e832d5c5871c6cb2fd8b2c1ae3dbd029.tar.gz arduino_projects_website-1fb3d381e832d5c5871c6cb2fd8b2c1ae3dbd029.tar.bz2 arduino_projects_website-1fb3d381e832d5c5871c6cb2fd8b2c1ae3dbd029.zip |
Add user registration, login and abstract submission interfaces
Diffstat (limited to 'arduino_blog/static/admin/js/autocomplete.js')
-rw-r--r-- | arduino_blog/static/admin/js/autocomplete.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/arduino_blog/static/admin/js/autocomplete.js b/arduino_blog/static/admin/js/autocomplete.js new file mode 100644 index 0000000..65c0702 --- /dev/null +++ b/arduino_blog/static/admin/js/autocomplete.js @@ -0,0 +1,37 @@ +(function($) { + 'use strict'; + var init = function($element, options) { + var settings = $.extend({ + ajax: { + data: function(params) { + return { + term: params.term, + page: params.page + }; + } + } + }, options); + $element.select2(settings); + }; + + $.fn.djangoAdminSelect2 = function(options) { + var settings = $.extend({}, options); + $.each(this, function(i, element) { + var $element = $(element); + init($element, settings); + }); + return this; + }; + + $(function() { + // Initialize all autocomplete widgets except the one in the template + // form used when a new formset is added. + $('.admin-autocomplete').not('[name*=__prefix__]').djangoAdminSelect2(); + }); + + $(document).on('formset:added', (function() { + return function(event, $newFormset) { + return $newFormset.find('.admin-autocomplete').djangoAdminSelect2(); + }; + })(this)); +}(django.jQuery)); |