CARVIEW |
Select Language
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 11 Oct 2025 15:01:42 GMT
Content-Type: text/html
Last-Modified: Wed, 18 Sep 2024 14:30:36 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
ETag: W/"66eae40c-2e94"
Reporting-Endpoints: csp-endpoint='https://csp-report-api.openjs-foundation.workers.dev/'
Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval' code.jquery.com; connect-src 'self'; img-src 'self' secure.gravatar.com; style-src 'self'; media-src 'self' content.jquery.com; report-uri https://csp-report-api.openjs-foundation.workers.dev/; report-to csp-endpoint
Content-Encoding: gzip
#7648 (data events don't trigger .live() event handlers) - jQuery - Bug Tracker
jQuery issues have moved to GitHub. This site is now a static archive of the old Trac bugs site. Some functions and pages are no longer available.
Skip to main content
Bug Tracker
Side navigation
#7648 closed bug (invalid)
Opened November 28, 2010 04:44PM UTC
Closed November 28, 2010 07:31PM UTC
data events don't trigger .live() event handlers
Reported by: | carlo.cabanilla@gmail.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.6 |
Component: | unfiled | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
It seems like the data events (setData, changeData, getData) aren't triggering event handlers set with .live(). A minimal test case:
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script> $(document).ready(function() { var logger = function(evt, key, val) { $('#log').append('<p>' + evt.type + ':' + key + ':' + val + '</p>') }; $('.container') .live('setData', logger) .live('getData', logger) .live('changeData', logger); $('#c1').data('a', 'foo'); $('#c1').data('a', 'bar'); $('#c1').data('a'); $('body').append('<div class="container" id="c2"></div>'); $('#c2').data('b', 1); $('#c2').data('b', 2); $('#c2').data('b'); var expected = [ "<p>setData:a:foo</p>", "<p>changeData:a:foo</p>", "<p>setData:a:bar</p>", "<p>changeData:a:bar</p>", "<p>getData:a:undefined</p>", "<p>setData:b:1</p>", "<p>changeData:b:2</p>", "<p>setData:b:2</p>", "<p>changeData:b:2</p>", "<p>getData:b:undefined</p>" ].join(""); var actual = $('#log').html(); if (actual == expected) { $('#message').append('Test passed'); } else { $('#message').append('Test failed. Expected: ' + expected + ' Actual: ' + actual); } }) </script> </head> <body> <div id="message"></div> <div class="container" id="c1"></div> <div id="log"></div> </body> </html>
Attachments (0)
Change History (2)
Changed November 28, 2010 05:33PM UTC by carlo.cabanilla@gmail.com comment:1
Changed November 28, 2010 07:31PM UTC by dmethvin comment:2
resolution: | → invalid |
---|---|
status: | new → closed |
Note that in jQuery 1.4.3 these events no longer bubble (allowing them to bubble proved to be too costly in most applications). -- https://blog.jquery.com/2010/10/16/jquery-143-released/
Bubbling is required for .live or .delegate to work.
At the moment, the data events are lightly documented so it's not advisable to write code that depends on them or their current behavior.
Oops, just noticed the message about using jsFiddle:
https://jsfiddle.net/5nPus/