Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better import of jQuery for the change_form that adds the jQuery.ui.t… #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Rui-Carvalho
Copy link

@Rui-Carvalho Rui-Carvalho commented Jun 8, 2019

See issue 35:

The error "Uncaught TypeError: $(...).tabs is not a function" is produced when using django-tabbed-admin under the following setup:

Django = 1.10.5
django-tabbed-admin=1.0.4
DEFAULT_JQUERY_UI_JS = 'tabbed_admin/js/jquery-ui-1.11.4.min.js'
The problem is that the code in jquery-ui-1.11.4.min.js is as follows:

/*! jQuery UI - v1.11.4 - 2015-07-27
(...)*/
jQuery = jQuery \|\| django.jQuery.noConflict(false); 

and the code on django-tabbed-admin uses it this way (change_form.html):

    <script type="text/javascript">
        (function($) {
            $(window).scrollTop()
            $('#tabs').tabs({
                {% if add %}
                // when adding, don't select a tab by default, we'll do it ourselves
                // by finding the first available tab.
                selected: -1
                {% endif %}
            });
        (....)
        })(django.jQuery);
    </script>
    <!-- end admin_tabs stuff -->

To sort this out this should be what would be passed in to the IIFE instead of the (django.jQuery) as above:

    <script type="text/javascript">
        (function($) {
            (....)
        })((typeof window.jQuery == 'undefined' && typeof window.django != 'undefined')
  ? django.jQuery
  : jQuery)
    </script>
    <!-- end admin_tabs stuff -->

@coveralls
Copy link

Coverage Status

Coverage remained the same at 89.971% when pulling 430c05d on Rui-Carvalho:Fixing-issue-35 into 82cf985 on omji:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants