I have a class
var a = Class.Create({
function initialize() {
var _items = [];
Object.defineProperties(this, {
'items': {
get: function () {
return Object.clone(_items);
},
enumerable: true
}
});
...
}
function indexOf(item) {
return -1;
}
});
then I create an instance of the class
var b = new a();
then I fill the _items with the data
[
{ name: 'Joe', last: 'Celko' },
{ name: 'Ivan', last: 'Susanin' }
]
and ovewrite the indexOf method with thw new one
b.indexOf = function(item) {
var index = -1;
var items = this.items;
items.detect(function(el, idx) {
var b = (el.name === item.name) (el.last === item.last);
b (index = idx);
return b;
});
return index;
};
then i try to seach
b.indexOf({ name: 'Joe', last: 'Celko' });
and always get -1 !!!
I try to debug and detect the this._each in Enumerable.each never goes
into, but if I chnge
return Object.clone(_items); --- return _items;
everything goes ok and returns 0! Why?
Help me please. I cannot expose original items because changes on it
maybe damaged
--
You received this message because you are subscribed to the Google Groups
Prototype script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.