This is a migrated thread and some comments may be shown as answers.

ObservableArray.splice broken in MVVM

3 Answers 92 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Nathan
Top achievements
Rank 1
Nathan asked on 03 May 2012, 01:04 PM
When you call the splice method of ObervableArray on an array that contains objects that have a field of "isNew" the following error is thrown:
Property 'isNew' of object [object Object] is not a function 

Here is a jsFiddle demonstrating the behavior:
http://jsfiddle.net/nbove/HgVEK/

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 04 May 2012, 11:11 AM
Hello Nathan,

The Model object used by the datasource has an isNew() method, which conflicts with the isNew field in this case. You can see it in kendo.data.js in the source. In other words, isNew is a reserved word and cannot be used freely. Sorry for any inconvenience caused.

All the best,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Nathan
Top achievements
Rank 1
answered on 09 May 2012, 01:37 PM
I wanted to follow up with two questions on this.  

1)  If you are going to be naming functions that are only to be used internally and are reserved, shouldn't they have names less likely to cause a conflict?  Something like _kendoIsNew() seems far more appropriate.  Alternatively, you could consolidate all of the kendo specific functionality on the model into a single kendo object.  That way you would have something along the lines of myModel.kendo.isNew().  In this way you could reduce your reserved words on a modeled object to a single word. 

2)  Where can I find a list of all of these reserved words?  It is very frustrating to have to navigate in the dark through a minefield of reserved names.
0
Dimo
Telerik team
answered on 09 May 2012, 02:07 PM
Hi Nathan,

1) The isNew() method is used by other widgets and is also part of the Kendo Model object API that can be used by anybody. That's why its name cannot be too complex.

2) The Model object is currently not documented, but we will take care of this. Sorry once again.

Greetings,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Nathan
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Nathan
Top achievements
Rank 1
Share this question
or