Modify ↓
Ticket #7028 (closed bug: duplicate)
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
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Dup of #6355.