PDA

View Full Version : Migrate version 1 to version 2



bia
13 Nov 2013, 6:11 AM
Uncaught TypeError: Cannot use 'in' operator to search for 'override' in undefined sencha-touch-all.js:35 (http://test.dokineo.net/html5_one/ressources/sencha-touch-all.js)

Ext.apply.define

(anonymous function) SearchResults.js


I have this error for most of the file used in my project, for example in this model "SearchResults.js"
Here is the code:

Ext.define('App.model.SearchResults'), {
// in version 1 it was: Ext.regModel('SearchResults', {

extend:'Ext.data.Model',
config:{
fields: [
{
name: 'issue_id',
type: 'int'
},
{
name: 'issue_title',
type: 'string'
},
{
name: 'issue_date',
type: 'string'
},
{
name: 'number',
type: 'int'
},
{
name: 'count',
type: 'int'
}
]
}
};

I replaced Ext.regModel with Ext.define.

If you have any ideea why is not working please write me.
Thanks you

keckeroo
13 Nov 2013, 7:45 AM
Looks like you have an extraneous ')' after your class name. Remove it and this should work



Ext.define('App.model.SearchResults', {
extend:'Ext.data.Model',

fields: [
{ name: 'issue_id', type: 'int' },
{ name: 'issue_title', type: 'string' },
{ name: 'issue_date', type: 'string' },
{ name: 'number', type: 'int' },
{ name: 'count', type: 'int' }
]
});

bia
14 Nov 2013, 6:01 AM
App = new Ext.app.Application({
tabletStartupScreen: 'images/loading-tablet.png',
phoneStartupScreen: 'images/loading-tablet.png',
icon: 'images/iconNew.png',
tabletIcon: 'images/iconNew.png',
phoneIcon: 'images/iconNew.png',
glossOnIcon: true,
name: "App",
client_id: '_',
lang: 'francais',
issue_id: 138,
pid: 138,


getParameterByName: function(name) {
var match = RegExp('[?&]' + name + '=([^&]*)')
.exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
},

models: ['Viewer', 'SearchResults', 'Bookmarks'],
controllers: ['Viewer', 'Pages', 'Chapters', 'Bookmarks'],
views: ['Viewport', 'viewer.Index', 'viewer.Contact', 'viewer.Library', 'viewer.Pages', 'viewer.Search', 'viewer.SearchLibrary',
'viewer.SearchKeyword', 'viewer.SearchKeywordDoc' , 'viewer.Share', 'viewer.Thumbnails', 'viewer.Bookmarks', 'viewer.BookmarksPop', 'viewer.Links', 'viewer.Help', 'viewer.Models'],
stores: ['Viewer', 'Pages', 'SearchResults', 'Bookmarks'],


launch: function() {
Ext.create('App'); // v2
alert('aa');
console.log(App.getParameterByName('pid'));
this.getController('App.controller.Viewer');
}
});


The function getParameterByName can be used in models, but the alert or the console.log is not shown ...
Infact I wanted to check if the controller Viewer.js is called/run with this line
this.getController('App.controller.Viewer');

Infact I was trying to replace the old code
Ext.dispatch({
controller: 'Viewer',
action: 'viewPages',
issue_id: App.getParameterByName('pid')
});

Thanks in advance, Bia

bia
14 Nov 2013, 6:09 AM
for your help

tobiu
14 Nov 2013, 6:09 AM
please do not post sencha touch related questions inside the ext js forums, or no one will find them.

take a look at this guide:
http://docs.sencha.com/touch/2.2.1/#!/guide/upgrade_1_to_2

you certainly don't want to use the new operator, create an instance of an application and create it again in its launch method.
the guide points out how to do it right (just Ext.application()).