Bug Tracker

Opened 13 years ago

Closed 13 years ago

#7648 closed bug (invalid)

data events don't trigger .live() event handlers

Reported by: carlo.cabanilla@… Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


It seems like the data events (setData, changeData, getData) aren't triggering event handlers set with .live(). A minimal test case:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
      $(document).ready(function() {
        var logger = function(evt, key, val) {
          $('#log').append('<p>' + evt.type + ':' + key + ':' + val + '</p>')
          .live('setData', logger)
          .live('getData', logger)
          .live('changeData', logger);
        $('#c1').data('a', 'foo');
        $('#c1').data('a', 'bar');
        $('body').append('<div class="container" id="c2"></div>');
        $('#c2').data('b', 1);
        $('#c2').data('b', 2);

        var expected = [
        var actual = $('#log').html();
        if (actual == expected) {
          $('#message').append('Test passed');
        } else {
          $('#message').append('Test failed. Expected: ' + expected + ' Actual: ' + actual);

    <div id="message"></div>
    <div class="container" id="c1"></div>
    <div id="log"></div>

Change History (2)

comment:1 Changed 13 years ago by carlo.cabanilla@…

Oops, just noticed the message about using jsFiddle:


comment:2 Changed 13 years ago by dmethvin

Resolution: invalid
Status: newclosed

Note that in jQuery 1.4.3 these events no longer bubble (allowing them to bubble proved to be too costly in most applications). -- http://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.

Note: See TracTickets for help on using tickets.