Bug Tracker

Modify

Ticket #7028 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

Data and event handling breaks with derivation from Array type

Reported by: mathbr Owned by:
Priority: undecided Milestone: 1.4.3
Component: unfiled Version: 1.4.2
Keywords: Cc:
Blocking: Blocked by:

Description

If one tries to derive from the base type "Array", neither data nor event handling work anymore. See the following example:

function Model() {
    this.push = function(item) {
        Model.prototype.push.call(this, item);
        $(this).trigger('added', [item]);
    };
};
Model.prototype = new Array;

var m = new Model();
$(m).data('test', 'TEST');
alert($(m).data('test'));

$(m).bind({
    'added': function(event, item) {
        alert('Item added: ' + item);
    }
});

m.push(42);

The value of the "test" data is suddenly undefined, the event "myEvent" is never fired.

Change History

comment:1 Changed 3 years ago by dmethvin

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to duplicate

Dup of #6355.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.