Hi,

The code you've quoted has a variety of syntax errors and typos, such
as using `function initialize()` within an object literal (which
results in an "Unexpected identifier" error) and using `Class.Create`
rather than `Class.create`. It's very hard to help when the code
presented is fundamentally broken and yet reported as working.

I recommend going back to first principles, building a minimal failing
test case, and if you don't solve the problem in the course of doing
that (which frequently happens), putting it on jsbin.com or
jsfiddle.net or similar and then linking to it so people can help you.
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Oct 17, 3:37 am, buda <[email protected]> wrote:
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to