asyncee / django-easy-select2

Select2 input widget for django selectable fields.
http://django-easy-select2.readthedocs.io/en/latest/
MIT License
214 stars 28 forks source link

Using tinyMCE reloads jQuery namespace, select2 registers in the new jQuery namespace #57

Closed jaikanthjay46 closed 5 years ago

jaikanthjay46 commented 5 years ago

I have this weird script order, jquery loads , jquery-ui registers itself, jquery.init.js where jQuery name space is cleared and moved to django.jQuery.

<script type="text/javascript" src="/admin/jsi18n/"></script>
<link href="/static/tabbed_admin/css/jquery-ui-1.11.4.min.css" type="text/css" media="all" rel="stylesheet">
<link href="/static/tabbed_admin/css/tabbed_admin.css" type="text/css" media="all" rel="stylesheet">
<link href="/static/easy_select2/vendor/select2/css/select2.min.css" type="text/css" media="screen" rel="stylesheet">
<link href="/static/easy_select2/css/easy_select2.css" type="text/css" media="screen" rel="stylesheet">
<script type="text/javascript" src="/static/admin/js/vendor/jquery/jquery.js"></script>
<script type="text/javascript" src="/static/tabbed_admin/js/jquery-ui-1.11.4.min.js"></script>
<script type="text/javascript" src="/static/easy_select2/js/init.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
<script type="text/javascript" src="/static/easy_select2/js/easy_select2.js"></script>
<script type="text/javascript" src="/static/django_tinymce/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
<script type="text/javascript" src="/static/easy_select2/vendor/select2/js/select2.min.js"></script>
<script type="text/javascript" src="/static/django_tinymce/init_tinymce.js"></script>
<script type="text/javascript" src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
<script type="text/javascript" src="/static/admin/js/actions.js"></script>
<script type="text/javascript" src="/static/admin/js/urlify.js"></script>
<script type="text/javascript" src="/static/admin/js/prepopulate.js"></script>
<script type="text/javascript" src="/static/admin/js/vendor/xregexp/xregexp.js"></script>
asyncee commented 5 years ago

Hello and thank you for bug report!

Sadly, i do not use django for a few years now, so this library is mainained by @gauravv7 and community.

Feel free to submit a PR :)

jaikanthjay46 commented 5 years ago

Thanks for taking notice, I wish there were more elegant ways to solve this @gauravv7, hit me up if you have some.

gauravv7 commented 5 years ago

@jaikanthjay46 all we want is to capture an instance of select2 to work upon, your approach seems fine. I ll do some more testing to figure more edge cases. basically we don't want to pick an object from unknown source, so as we get unknown behavior. JS allows us monkey-patching.