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

Already on GitHub? Sign in to your account

Uncaught TypeError: Object [object Object] has no method 'live' #463

Closed
user0007 opened this Issue Nov 19, 2013 · 5 comments

Comments

Projects
None yet
3 participants

Hello,

I've got an error when include latest jQuery in my template. Everything works fine when I remove jQuery.

Django 1.6
Chrome (latest) / Firefox (latest)
Ubuntu 12.x
jQuery 2.0.3

Error:

Uncaught TypeError: Object [object Object] has no method 'live' ____ toolbar.js:19
djdt.init ______________________________________________ toolbar.js:19
l ___________________________________________________ jquery-2.0.3.js:2913
c.fireWith ____________________________________________ jquery-2.0.3.js:3025
x.extend.ready _______________________________________ jquery-2.0.3.js:398
S ___________________________________________________ jquery-2.0.3.js:93

<html>
<body>

    ...

    {% block extrajs %}
        <script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
    {% endblock extrajs %}
</body>
</html>
Contributor

aaugustin commented Nov 22, 2013

Since #440 the debug toolbar uses the version of jQuery available in the page if there is one.

However the JavaScript code wasn't made compatible with the latest version of jQuery.

I've made a few improvements but I don't know how to deal with the .live() calls that remain in toolbar.js.

/cc @singingwolfboy

Contributor

singingwolfboy commented Nov 22, 2013

You want to switch the .live() calls to use .on(). jQuery has some documentation on how to do that at http://api.jquery.com/live/

Contributor

aaugustin commented Nov 22, 2013

Unfortunately, unlike live, on doesn't apply to elements added the DOM after the event handler is registered, and the jQuery docs don't address that :(

Contributor

singingwolfboy commented Nov 22, 2013

Sure it does -- just apply the handler to the document. For example:

$('#djDebugPanelList li a').live('click', function() {...})

becomes

$(document).on("click", "#djDebugPanelList li a", function() {...})
Contributor

aaugustin commented Nov 22, 2013

Oooooh I see. Thank you.

@aaugustin aaugustin closed this in 3209c8e Nov 23, 2013

ryneeverett pushed a commit to ryneeverett/django-debug-toolbar that referenced this issue Oct 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment